Welcome! Log In Create A New Profile

Advanced

Reverse proxy and rewrite. Need help !

Posted by blitter 
Reverse proxy and rewrite. Need help !
March 03, 2010 04:48AM
Hey nginx gurus,

I have two domains, [b]domain.net[/b] and [b]domain.com[/b] 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
[size=small]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;
}[/size]

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 [b]drupal[/b] 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
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 121
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready