I have this configuration :
location / {
root /etc/nginx/euchet;
}
location /app/ {
proxy_pass http://172.16.184.2:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE_ADDR $remote_addr;
}
And I need to add another location with auth_basic
enabled only for the request: /app/f?p=3000
I tried with rexexp:
location ~ \/appt\/f\?p=3000 {
auth_basic "Hello! Enter password";
auth_basic_user_file /etc/nginx/euchet.htpasswd;
proxy_pass http://172.16.184.2:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE_ADDR $remote_addr;
}
Nginx use previous location /app/
.
I tried another way:
location ~* /euchet/f {
if ($arg_p = "4550") {
return 403;
}
error_page 403 = @hidden;
}
location @hidden {
auth_basic "Hello! Enter password";
auth_basic_user_file /etc/nginx/euchet.htpasswd;
proxy_pass http://172.16.184.2:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE_ADDR $remote_addr;
}
And I get 403 error on f?p=3000
, and 404 errors on f?p=<another_number>
How can I fix this problem?