Tuesday, 15 June 2010

ubuntu - How to proxy nginx request while keeping same url -


I am using a self hosted service stack app with this configuration so when I read mysite.com/json If browsing / reply / mytestmethod, I'm redirected to mysite.com:1337/json/reply/mytestmethod. The app works fine except for the help of the removal of port 1337, and it comes from mysite.com domain.

Cheers!

  server {80; Server_name mysite.com; Root /var/www/mysite.com/html; Index index.html; Location / {proxy_set_header X-real-IP $ remote_edder; Proxy_set_header host $ http_host; Proxy_Code http://127.0.0.1:1337; }}  

If you want to strip the port, then you use a reverse Instead of the redirect, a typical reverse proxy configuration looks like this in proxy Nginx:

  server {80 says; Server_name mysite.com; Location / {proxy_pass http: // localhost: 1337 /; Proxy_redirect closed; Proxy_set_header X-real-IP $ remote_adder; Proxy_set_header X-Forward- $ proxy_add_x_forwarded_for; Proxy_set_header host $ http_host; Proxy_set_header X-NginX-Proxy True; }}  

No comments:

Post a Comment