nginx configuration code is like this
server {
listen 80 default_server;
listen [::]:80 default_server;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
root /home/ubuntu/card/public;
try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:3000;
}
}
There is no problem with the node program itself
My understanding is that if try_files is unsuccessful, the express server should try to respond
Suppose there is a folder called uploads under your directory
/home/ubuntu/card/public
, and the nginx configuration is as followsThen accessing http://localhost/ will jump to nodejs, and http://localhost/uploads/ will access the static files under
/home/ubuntu/card/public/uploads
.