Hey ,
I have two domains, domain.net and domain.com and considering the
expected lack of IP addresses I want to setup a sites hub/reverse proxy.
Nginx 0.7.6x is installed on a debian 5.x box and works fine so far. Now
I’m stuck with this 4 cases scenario:
-
www.domain.net ----> nginx ------(no rewrite)------>
internal-www.domain.net box
Nginx should pass the whole url to the internal box. Here’s my config
server {
listen 80;
server_name www.domain.net;
#charset koi8-r;
access_log logs/www.domain.net.access.log;
location / {
proxy_pass http://internal-www.domain.net;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
-
www.domain.com ----> nginx ------(rewrite)------>
internal-com.domain.net box
nginx should rewrite the base url (http://www.domain.com to
http://com.domain.net before passing it to the internal box)
ex : Website Domains Names & Hosting | Domain.com rewritten to
http://com.domain.net/index.html and send to the box
-
pub.domain.net/alias1 ----> nginx ------(rewrite)------>
internal-pub.domain.net box
nginx should rewrite the url to remove the “/alias1†part before passing
it to the internal box (which is a drupal site…).
ex : http://pub.domain.net/alias1/index.php rewritten to
http://pub.domain.net/index.php and send to the box
-
pub.domain.net/alias2 ----> nginx ------(rewrite)------>
internal-alias2.domain.net box
nginx should rewrite the url from pub.domain.net/alias2 to
alias2.domain.net part before passing it to the internal box
ex: http://pub.domain.net/alias2 rewritten to http://alias2.domain.net
and send to the box.
After some hair pulling, a lot of “Should I use proxy_pass or
proxy_redirect ?†and “is drupal messing with somethingâ€, any help would
be really appreciated.
Thanks
Blitter
On Fri, Mar 05, 2010 at 03:18:17PM +0100, Da Blitter wrote:
server {
proxy_set_header Host $host;
alias2.domain.net part before passing it to the internal box
ex: http://pub.domain.net/alias2 rewritten to http://alias2.domain.net
and send to the box.
After some hair pulling, a lot of “Should I use proxy_pass or
proxy_redirect ?†and “is drupal messing with somethingâ€, any help would
be really appreciated.
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
server {
server_name www.domain.net;
location / {
proxy_pass http://internal-www.domain.net;
}
}
server {
server_name www.domain.com;
location / {
proxy_pass http://internal-com.domain.net;
}
}
server {
server_name pub.domain.net;
location /alias1/ {
proxy_pass http://internal-pub.domain.net/;
}
location /alias2/ {
proxy_pass http://internal-alias2.domain.net/;
}
}
–
Igor S.
http://sysoev.ru/en/
On Fri, Mar 05, 2010 at 05:32:11PM +0300, Igor S. wrote:
internal-www.domain.net box
proxy_pass http://internal-www.domain.net;
ex : http://www.domain.com/index.html rewritten to
internal-alias2.domain.net box
nginx should rewrite the url from pub.domain.net/alias2 to
alias2.domain.net part before passing it to the internal box
ex: http://pub.domain.net/alias2 rewritten to http://alias2.domain.net
and send to the box.
After some hair pulling, a lot of “Should I use proxy_pass or
proxy_redirect ?†and “is drupal messing with somethingâ€, any help would
be really appreciated.
proxy_set_header Host $host;
“Host” is probably is not needed.
server {
}
location /alias2/ {
proxy_pass http://internal-alias2.domain.net/;
}
}
Also you should not disable proxy_redirect, if backend send such
redirects:
Location: http://internal-www.domain.net/some/url
Location: http://internal-pub.domain.net/another/url
–
Igor S.
http://sysoev.ru/en/
location /alias2/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://alias2.domain.net/;
proxy_redirect default;
}
When I type http://pub.domain.net/alias2 in a browser, I can reach the
backend machine with this url but the displayed page is messy. Is there
any way to rewrite/force the url in the browser ?
Blitter
Thanks for your help Igor.
I still have some issues but I’ll make some new tries on monday.
Blitter