I'm trying run the frontend (react
) and a backend (nodejs,
express) from a same
ubuntu 20.4` machine but for some reason my nginx is not mapping correctly. I don't know if I have a typo somewhere or just configured something wrong?
Inside /etc/nginx/sites-enabled/
I have created 2 files one for the frontend
and one for the backend
The contents inside the backend
file are the following:
server {
# server_name ## add server name
server_name backend.develop.mysite.be; // Dummy name for SO, but actual file contains the right address
location / {
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
proxy_send_timeout 1800;
send_timeout 1800;
proxy_pass http://localhost:9000; // [ASK]: Is this is what is causing the problem? Maybe I should change it to 3000 ?
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/frontend.develop.mysite.be/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/frontend.develop.mysite.be/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = backend.develop.mysite.be) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name backend.develop.mysite.be;
return 404; # managed by Certbot
}
the contents for the frontend
are very similar just with a different name. In the past this setup worked for me, but for some reason right now I'm getting a 502 BAD Gateway
response error but only for the backend
. The frontend
seems to work just fine.