Welcome! Log In Create A New Profile

Advanced

Re: proxy + rewrite

March 05, 2012 06:30PM
On 03/05/2012 02:46 PM, Alex Alex wrote:
> Hi all,
>
> I'm new with NGINX. What I want to do is a front reverse proxy server
> that rewrites URL.
>
> I actually can make it working with one site, but not with many sites.
>
>
> On my real server:
>
> https://srvabc:1234/mypath/ goes
> https://srvabc:1234/mypath/connexion.do?action=init
>
> and on my NGINX server:
>
> https://www.mynxinx/abc goes
> https://www.mynxinx/abc/connexion.do?action=init
>
> What is not working is to have https://www.mynxinx/def going on another
> server like https://srvdef:4567/anothermypath/
>
> I tried many configurations and the most simple one seems to be the one
> using the request_uri without the / at the beginning (I also tried
> directly with proxy_pass https:/$request_uri;):
>
> upstream abc {
> server srvabc:1234 weight=10 max_fails=3 fail_timeout=30s;
> }
>
> upstream def {
> server srvdef:4567 weight=10 max_fails=3 fail_timeout=30s;
> }
>
> server {
> listen 443 ssl;
> server_name mynxinx;
>
> ssl on;
> ssl_certificate /etc/nginx/cert.pem;
> ssl_certificate_key /etc/nginx/cert.key;
>
> ssl_session_timeout 5m;
>
> ssl_protocols SSLv2 SSLv3 TLSv1;
> ssl_ciphers HIGH:!aNULL:!MD5;
> ssl_prefer_server_ciphers on;
>
> location / {
>
> if ($request_uri ~* ^/(.*)$) {
> set $request_key $1;
> }
>
>
> rewrite /abc /mypath;
> rewrite /def /anothermypath;
>
> proxy_pass https://$request_key;
> 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;
>
> }
> }
>
> What's wrong my my configuration?
>

Instead of this way, consider using the map directive:

http://wiki.nginx.org/HttpMapModule

The example in the synopsis seems very similar to what you are trying to
achieve.

Regards,
Cliff


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

proxy + rewrite

Alex Alex March 05, 2012 05:48PM

Re: proxy + rewrite

Cliff Wells March 05, 2012 06:30PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 226
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready