Reputation: 4809
I'm using a self hosted service stack app with this configuration. So when I browse mysite.com/json/reply/mytestmethod I get redirected to mysite.com:1337/json/reply/mytestmethod. the app works fine except looking for help in removing the port 1337 part and make it appear to come from the mysite.com domain.
Cheers!
server {
listen 80;
server_name mysite.com;
root /var/www/mysite.com/html;
index index.html;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:1337;
}
}
Upvotes: 2
Views: 308
Reputation: 143374
If you want to strip the port you'll want to use a reverse proxy rather than redirect. In nginx a typical reverse proxy configuration looks like:
server {
listen 80;
server_name mysite.com;
location / {
proxy_pass http://localhost:1337/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
}
Upvotes: 2