This tutorial is suitable for you if you want to access some apps with one domain, just different path /
- You can access on
localhost
to accesslocalhost:5000
- You can access on
localhost/nodejs
to accesslocalhost:3000
nano /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name res.bignetlab.com www.res.bignetlab.com;
return 301 https://$host$request_uri;
}
server {
listen 80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
if ($host != "res.bignetlab.com") {
return 412;
}
server_name res.bignetlab.com www.res.bignetlab.com;
ssl_certificate /etc/ssl/certs/res/res.crt;
ssl_certificate_key /etc/ssl/certs/res/res.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
location / {
proxy_pass http://127.0.0.1:5000;
}
location /nodejs/ {
proxy_pass http://127.0.0.1:3000/;
}
}
service nginx reload
If you want to redirect from https://localhost.com
to https://another-localhost.com
you can use :
# backend.wants.this.server.com
# browser.shows.this.server.com
server {
listen 80;
server_name browser.shows.this.server.com;
location / {
proxy_set_header Host backend.wants.this.server.com;
proxy_redirect http://backend.wants.this.server.com/ http://browser.shows.this.server.com/;
}
}