1

I have deployed nodebb application on nginx, and trying to combine with my site.

My site is http://example.com. I successed to show node app on http://example.com:4567 either http://example.com(port number removed).

However, I'd like to show them with the url like http://example.com/nodebb.

I tried like the code below.

config.json

{
    "url": "http://example.com/nodebb",
    "secret": "secret",
    "database": "mongo",
    "port": 4567,
    "mongo": {
        "host": "127.0.0.1",
        "port": "27017",
        "username": "nodebb",
        "password": "pass",
        "database": "nodebb"
    }
}

nginx.conf

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_pass http://127.0.0.1/nodebb:4567;
    proxy_redirect off;
    # Socket.IO Support
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

However, it returned "not found". I have no idea how to make new slug and put node app into it. Any help is appreciated.

  • 1
    There is a mistake in your nginx code... the proxy_pass value should be : http://127.0.0.1:4567/nodebb; – night-gold Jan 15 '19 at 17:16
  • 1
    Thank you very much @night-gold! now I could access to http://example:4567/nodebb. but I couldn't open http://example/nodebb... is there any way to remove port number with this way? – Kohei Murakami Jan 16 '19 at 05:36

1 Answers1

1

You have the right answer to the problem, you just need to add more options to your proxy_pass to completely resolve your problem.

I think this post answers your question: https://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite

night-gold
  • 2,202
  • 2
  • 20
  • 31