I am trying to set up nginx to behave as a reverse proxy listening on a subdomain we control. I have followed examples found online and they mostly work with one exception that isn't clear to me.
Inspect the server block below:
server{
listen *:80;
server_name placehold.com;
charset utf-8;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log error;
location / {
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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
proxy_pass http://google.com/;
}
}
google.com is a placeholder for this test.
If i visit a url like "http://placehold.com/test" this works perfectly, it redirects me to some google error page and the url in the browser stays as types. But if I put a bare url like "http://placehold.com/" then it redirects my browser to the google homepage, the google url clearly showing in the browser.
How can I get the reverse proxy to properly mask the url for '/' urls as well as '/with/some/path' urls?