Have a webapp on - Redirect to subdomain with nginx?

Posted June 29, 2015 2.5k views


I’m setting up a forum (NodeBB to be exact) on my Ubuntu 14.04 vps and have it up on How would I go about routing this to using nginx? Here’s what I have for my DNS:

$TTL 1800 IN SOA 000000000 00000 0000 000000 0000 1800 IN NS 1800 IN NS 1800 IN NS 1800 IN A 1800 IN CNAME
* 1800 IN CNAME 1800 IN CNAME 1800 IN CNAME

I have no clue what to use in my nginx config. I tried just doing a basic listen on port 4567 with a new sites-enabled config (as if it were a completely different domain) but would still just redirect to


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

This should do the trick:

server {
  listen 80;

    location / {
        proxy_pass http://localhost:4567;


This defines a server listening at port 80 on the subdomain proxying requests to the server running at port 4567 on localhost. Be sure to restart nginx after you make the change:

service nginx restart