How can I set up a domain or subdomain to point to my web server listening on a different (non-standard) port?

Linode Staff

I'm running a node.js app my server which is using port 80. But now I need to run a standard http web server, so I need to use a different port (8080). How can I point my domain or subdomain to my server using a different port?

1 Reply

The DNS system doesn't explicitly allow you to specify a port number when you create A/AAAA records. Though, in limited cases, an SRV record can be used to direct traffic to a specific port number (What is an SRV record?). However, this isn't something that is supported by browsers (most just look for port 80/443 connections by default and don't request SRV records).

One work around would be to put a reverse proxy (like Nginx) in front of both of your applications. Any requests for your domain and/or subdomain would first reach Nginx, and then Nginx would pass the connection to a different server (like the node.js server or Apache running WordPress).

In your situation, you could have your node.js app listen on 8000 (for example.com), then have another website running WordPress on Apache listening on 8080 (for subdomain.example.com). Nginx would be configured to pass traffic off to either service.

Here are a few useful resources:
Use NGINX as a Reverse Proxy
How to set up two node apps and work with nginx
NGINX Documentation

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct