Reverse proxy and rewrite. Need help !

Da Blitter lists at ruby-forum.com
Fri Mar 5 17:18:17 MSK 2010


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:

1. 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;
}

2. 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 : http://www.domain.com/index.html rewritten to
http://com.domain.net/index.html and send to the box

3. 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

4. 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
-- 
Posted via http://www.ruby-forum.com/.



More information about the nginx mailing list