Nginx – What does location ^~ mean in an nginx location block

nginx

I am looking at an nginx location block that has this symbol ^~ before the location block. What does it do? I am having a hard time googling for it.

location ^~ /realestate/ {
    uwsgi_pass 127.0.0.1:2340;
    include /etc/nginx/uwsgi_params;
}

Best Answer

^ is the start of a match on the uri ~ indicates a regular expression match

/realestate/ without an explicit end will match on a uri beginning with /realestate/ in this case when using a regex match

More explicitly if your intent is to match on /realestate/ exactly location = /realestate/ would be a faster more optimized match

If your intent is really something like

location ^~ /realestate/.* this might be a little more accurate way to represent it