Hello,
The Nginx configuration is as below:
upstream nodejs {
server nodejs:3000;
}
server {
listen 80;
server_name default_server;
error_log /var/log/nginx/error.system-default.log;
access_log /var/log/nginx/access.system-default.log;
charset utf-8;
root /usr/share/nginx/html;
index index.html index.php index.js;
location ~ \.js$ {
proxy_pass http://nodejs;
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;
}
location / {
autoindex on;
try_files $uri $uri/ $uri.html =404;
}
}
Why I got the following error:
# curl localhost/app.js
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.25.4</center>
</body>
</html>
Thank you.