0

I have setup two servers with nginx -

  1. https://dev.imagecompressor.io at 35.231.119.158
  2. https://imagecompressor.io at 176.9.41.138

I am trying to forward https://imagecompressor.io/site to https://dev.imagecompressor.io/site & want the url remain https://imagecompressor.io/site.

Forwarding is doing ok but the subdirectory /site/ seems to be omitted & URL is also changed.

NGINX configuration at 176.9.41.138

location /site/ {
        proxy_pass http://dev.imagecompressor.io;
        # error_log /var/log/nginx/site_error.log debug;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host imagecompressor.io;
        # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
A G
  • 163
  • 1
  • 7

1 Answers1

0

I think you must change this line:

proxy_pass http://dev.imagecompressor.io;

to this:

proxy_pass http://dev.imagecompressor.io/site;

And if you want to change URL to new URL use this:

proxy_set_header Host  http://dev.imagecompressor.io;

else you can use it:

proxy_set_header Host $host; 
Madvin
  • 101
  • 1
  • Suffixing `/site` does not seem to work. 301 redirect is still to https://dev.imagecompressor.io/. `$host` has no effect at all. – A G Feb 12 '19 at 16:55
  • Sorry that I replied so late, I will test it and update my answer soon. – Madvin Mar 20 '19 at 23:02