bvpx
bvpx

Reputation: 1287

node.js application running on a port should have no port visible in the URL bar

I have 5 domains pointing to the same machine, let's say these domains are:

example1.com
example2.com
example3.com
example4.com
example5.com

If I connect to any of the 5 domains, and type :3000 at the end, I can see the node.js app splash screen.

For example, if I connect to example1.com:3000 it serves me the same page (the node.js app) that can be reached by connecting to example2.com:3000 and example3.com:3000, etc. I understand why this is happening.

However, I am trying to edit my configuration such that the following criteria are met:

I have searched and found some information which leads me to believe this is normally achieved by setting up a reverse proxy, but most examples I find are using nginx or node. It would be nice to figure out a reverse proxy solution with apache so I don't have to re-write all my virtual host logic with node or nginx.

Upvotes: 0

Views: 326

Answers (1)

frenchie4111
frenchie4111

Reputation: 399

You need to set up a reverse proxy. An easy way to do this is to use nginx. Install and start nginx and in your config file put the following:

server {
    listen 80;
    server_name example1.com;

    location / {
         proxy_pass http://localhost:3000;
    }
}

And then run your node server on port 3000.

Upvotes: 1

Related Questions