Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6015

Using NGINX as a reverse proxy to serve webservers on same server [closed]

$
0
0

I'm trying to implement Nginx as a reverse proxy to serve different web apps via subdomains and can't seem to find any beginner friendly guides on how to do so.

Example:

  • cloud.mydomain.com => [local] 192.168.0.33:5000;
  • web.mydomain.com => [local] 192.168.0.33:5001;

The idea is to open port 80 and 443 on my router and then forward all traffic towards the reverse proxy which then talks to the respective server (specified via the subdomain configs) on my LAN and passes the request back to the client.

What I've tried so far (without any luck though):

1) Editing the default file in /etc/nginx/sites-available/ to look somewhat like this:

server {    listen 80;    server_name cloud.mydomain.com;    location / {        proxy_pass http://localhost:5000/;    }}server {    listen 80;    server_name node2.mydomain.com;    location / {        proxy_pass http://localhost:5001/;    }}

This would result in ANY subdomains pointing to whatever I specified in the first block :(

2) Unlinking the default file, creating a new test.conf file under /etc/nginx/sites-available/ and linking it to /etc/nginx/sites-enabled/ (nginx -t didnt report any errors). The config was same as above.

Setup: I'm running Ubuntu Server 19.10. I do a domain name and I've already setup the subdomains as CNAME records.

Note: I do not want to use Nginx as a web server. I'm trying to use it for node.js web apps, DBs, my nextcloud etc.

Note 2: I only care about subdomains right now. Yes, I will need to add SSL configs and such but once I understand how to do proper configs I'll be able to figure all that out using the docs (I hope? lol).


Viewing all articles
Browse latest Browse all 6015

Trending Articles