mardi 21 janvier 2020

Stop, break or abort Nginx location if file exists

I have something like this in Nginx conf:

location ~ \/([0-9.]+)\/([0-9]+) {

proxy_set_header HOST $host;
proxy_pass http://$1:$2/;
}

Let's suppose I shoot in url localhost/178.33.71.162/5038

I wanna stop/break/abort if there is a file in root_www like 178.33.71.162/5038

I tried doing between { and proxy_set_header (just after the location start):

if (-f $document_root$1/$2) {
break;
}

Or

if (-f $document_root$1$2) {
break;
}

Or even for testing purposes putting the 5038 file in root WWW:

if (-f 5038) {
break;
}

And none of this works and the proxy_pass is being executed. How to make it right?

Aucun commentaire:

Enregistrer un commentaire