Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'd like to set up multiple node.js servers on the same machine (but listening on different ports) for different projects (so I can pull any down to edit code without affecting the others). However I want to be able to access these web apps from a browser without typing in the port number, and instead map different urls to different ports: e.g. 45.23.12.01/app -> 45.23.12.01:8001.

I've considered using node-http-proxy for this, but it doesn't yet support SSL. My hunch is that nginx might be the most suitable. I've never set up nginx before - what configuration do I need to do? The examples of config files I've seen only deal with subdomains, which I don't have.

Alternatively, is there a better (stable, hassle-free) way of hosting multiple apps under the same IP address?

share|improve this question

2 Answers 2

First start with reading the wiki documentation. It's very thorough and includes samples. I won't give you an entire nginx config, but here is the relevant portion to your question.

server {
    listen 80;
    server_name example.com;

    location /foo {
        proxy_pass http://localhost:9000;
    }

    location /bar {
        proxy_pass http://localhost:9001;
    }

    location /baz {
        proxy_pass http://localhost:9002;
    }
}

It should be clear what's going on there. Each location proxies the specified URI to the appropriate node.js backend.

share|improve this answer

nginx might be the way to go. At least, that is what I have running on my server. An example config/description can be found here: http://wellconsidered.be/nodejs-on-nginx

You basically set up different sites in nginx and each site routes his traffic to a nodejs app running on a different port.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.