proxy + rewrite
Alex Alex
lists at ruby-forum.com
Mon Mar 5 22:46:09 UTC 2012
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?
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list