I have multiple nodejs apps from different domains that I am serving from the same server with nginx. I am currently starting each app on a different port say 5000, 5001, 5002 ect. Then using nginx proxy_pass to serve them from the ssl port 443 like so:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mydomain.com;
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2;
include snippets/ssl-params.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-NginX-Proxy true;
proxy_pass http://localhost:5000/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
}
And I am setting up a block just like this for each domain/app.
I have a couple questions I guess:
- What ports should I be starting the apps on so I can avoid conflicts. Are there standard ports that I should be using?
- Is this the way I should be doing this or is there a better way to go about this.
I read that ports above 49151 are for arbitrary uses. Should I be starting my apps in those ports above 49151?
Any guidance would be appreciated here. I am a web developer and don't have a lot of experience with the server side of things.