Reputation: 11
I have successfully setup virtual hosts in nginx so that I can access the website with two domains. What I'd like to do is to forward domain2.com to domain1.com/test but without redirecting it to domain2.com/test. My current virtual host configuration for domain2.com looks like this:
server {
listen 80;
listen [::]:80;
server_name domain2.com www.domain2.com;
location / {
proxy_pass http://domain1.com/test;
}
}
But when accessing domain2.com, I'm redirected to domain1.com/test.
In short, I'd like to access domain1.com/test under domain2.com.
Upvotes: 1
Views: 847
Reputation: 48
You can add proxy_set_header Host domain2.com
in your location
location / {
proxy_pass http://domain1.com/test/;
proxy_set_header Host domain2.com
}
Upvotes: 0