I am trying to masking a remote URL with Nginx using proxy_pass
I'd like to load staging.saas.localhost/_ when the browser url is saas.localhost/uk_staging.
For some reason the location in saas.localhost is not working, and for not working I mean that the location seems to be ignored.
saas.localhost/uk_staging is handled by the application and not from staging.saas.localhost/_, it seems to me that even for saas.localhost/uk_staging the location used is location ~ .php$
I created a 2nd domain t.saas.localhost and it is working as expected
The t.saas.localhost domain is working perfectly fine.
t.saas.localhost/uk_staging is displaying staging.saas.localhost/_ t.saas.localhost/anything_else is displaying google.co.uk/
This is my current Nginx conf:
server {
listen 80;
server_name saas.localhost www.saas.localhost staging.saas.localhost;
root /codebase/saas;
index index.php index.html index.htm;
location /uk_staging {
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://staging.saas.localhost/_;
}
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?action=$1 last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 600;
}
}
server {
listen 80;
server_name t.saas.localhost;
root /codebase/saas;
index index.php index.html index.htm;
location /uk_staging {
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://staging.saas.localhost/_;
}
location / {
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://google.co.uk;
}
}