So i have 4 frontends that i needed to be accessed by public, but i want to specify an user friendly like example.com/lcd instead of example.com:3002. I want this for all those ports, 3001, 3000 and 3003 too. What i have now is the following example.pt.conf:
server {
listen 80;
listen [::]:80;
server_name example.pt www.example.pt;
location / {
proxy_pass http://localhost:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /window/ {
proxy_pass http://localhost:3001/;
rewrite ^/window(.*) /$1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /lcd/ {
proxy_pass http://localhost:3002/;
rewrite ^/lcd(.*) /$1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /machine/ {
proxy_pass http://localhost:3003/;
rewrite ^/machine(.*) /$1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
And a .conf for each frontend, with the same code as the following but with the diferent paths and ports:
server {
listen 3003;
listen [::]:3003;
root /var/www/machine/build;
index index.html index.htm index.nginx-debian.html;
server_name example.pt www.example.pt;
location /machine/ {
try_files $uri $uri/ /index.html =404;
}
}
It does not work as intended. Can someone help with this?
Thanks in advance.
Tiago Pacheco is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.