When i set Host header sent to upstream server to $proxy_host i get the the requested page but the url is changed in the browser to the upstream url.
...
proxy_set_header Host $proxy_host;
proxy_pass ...
the above works fine except that the url in the browser changes and shows the upstream url instead of the url that the user entered - we want the user's url to be shown
To remedy that When i send $host instead then i get an error in the browser saying that connection was refused.
...
proxy_set_header Host $host;
proxy_pass ...
This gives the connection was refused error - I am not sure if this error is generated by nginx or it is generated by my upstream server. I do not control much about what the upstream server expects as that is a call to s3 storage (object storage) over http on DO.
Is there a way to diagnose where the error is coming from and if it is from the upstream server how can i still have the user get the same url in their browser while passing the $proxy_host to the upstream?
Does passing $proxy_host to the upstream affect the user's browser? By what mechanism?? Should it not only affect what is going to the upstream server? Why does the browser behavior change? Please can anyone shed light on this behavior? Thank you in advance.
*EDIT - including full server context below as requested:
server {
listen 80;
server_name example.com;
location / {
rewrite ^(.*)/$ $1/index.html break;
rewrite ^(.*/[^./]+)$ $1/index.html break;
proxy_set_header Host $proxy_host;
proxy_pass http://someotherexample.com;
}
}