Reputation: 9049
I have a domain like so:
And I need to map it to a particular url from another domain on the same server:
Is this possible without redirecting the source? How do I specify this in a server directive in nginx?
Thanks!
Upvotes: 2
Views: 4874
Reputation: 401
Use the proxy pass directive. Example:
server {
listen 80;
server_name source.com;
location / {
proxy_next_upstream error timeout invalid_header http_500;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host source.com;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://target.com/source/;
}
}
There's more documentation on the nginx wiki here: http://wiki.nginx.org/HttpProxyModule#proxy_pass
Upvotes: 5
Reputation: 12785
When you say you do not want to redirect, I take this to mean you want the "source" url to remain in the address bar but for the files to be served from the "source" folder in "target".
As long as target is on the same server, you can simply just specify the root for source to point to the relevant folder.
server {
server_name source.com;
root /var/www/target.com/public_html/source;
location / {
...
}
...
}
Upvotes: 0