I want http://example.com
to map to a subpage from somewhere else:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://somewhere.com/foo;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
}
The problem is that this page will load stuff like
<script src="/assets/script.js">
which will then be attempted to get loaded from http://example.com/assets/script.js
- but this will actually go to http://somewhere.com/foo/assets/script.js
instead of http://somewhere.com/assets/script.js
So how can I convince nginx to just map the root domain - http://example.com
to http://somewhere.com/foo
and everything else to http://somewhere.com/*
?
I tried many things but couldn't get it to work...