Welcome! Log In Create A New Profile

Advanced

Re: Reverse proxy and rewrite. Need help !

March 05, 2010 09:42AM
On Fri, Mar 05, 2010 at 03:18:17PM +0100, Da Blitter wrote:

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

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 Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Reverse proxy and rewrite. Need help !

Da Blitter March 05, 2010 09:22AM

Re: Reverse proxy and rewrite. Need help !

Igor Sysoev March 05, 2010 09:42AM

Re: Reverse proxy and rewrite. Need help !

Igor Sysoev March 05, 2010 09:42AM

Re: Reverse proxy and rewrite. Need help !

Da Blitter March 05, 2010 11:28AM

Re: Reverse proxy and rewrite. Need help !

Da Blitter March 08, 2010 04:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 135
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