I cannot figure out how to reslove the 404 error while refreshing.
here is related part of my config:
server {
server_name example.com;
location / {
proxy_pass http://192.168.x.y:5000; # Proxy requests to Node web server on port 8000
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 /api {
proxy_pass http://192.168.x.y:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_cache_bypass $http_upgrade;
}
}
server {
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name example.com;
listen 80;
return 404; # managed by Certbot
}
I have also tried to use the try_files inside ” location / ” section but did not work or maybe I did it wrong.
try_files $uri $uri/ /index.html =404;
my index.html is serverd in web server in this path:
/home/ubuntu/web_server/public/index.html
which mounts through a docker container like this
volumes:
- ./nginx_data:/etc/nginx/conf.d # Nginx configurations
- /etc/letsencrypt/:/etc/letsencrypt/ # Certificates for https
New contributor
Shahab Fazeli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.