Simple redirect from :3000 to the domain itself

March 6, 2015 1.1k views
Nginx

I read and applied all I can to redirect ilearnsmarter.com:3000 to ilearnsmarter.com but it simply doesn't work. On port 3000 I am currently running node.js app, but I need the requests to port 3000 to be redirected to the domain itself. Any suggestions?
//-------------------------
Update:
I manage to make request to the domain to act as redirect to port 3000 with the common:
location / {
proxypass http://localhost:3000/;
proxy
redirect off;
proxysetheader X-Real-IP $remoteaddr;
proxy
setheader X-Forwarded-For $proxyaddxforwardedfor;
proxy
setheader Host $httphost;
proxysetheader X-NginX-Proxy true;
}
//note: Digitalocean tutorial's similar code was not working
Still, request to port 3000 doesn't redirect to the domain. Maybe changing one of the above flags can solve it, but I don't play bingo.

2 comments
  • Paste full configuration file

  • The configuration is:
    //-------------------------
    server {
    listen 80;

    server_name ilearnsmarter.com;
    

    location / {
    proxypass http://localhost:3000/;
    proxyredirect off;
    proxysetheader X-Real-IP $remoteaddr;
    proxysetheader X-Forwarded-For $proxyaddxforwardedfor;
    proxysetheader Host $httphost;
    proxysetheader X-NginX-Proxy true;
    }
    }

Be the first one to answer this question.