The original post: /r/nginx by /u/peoples888 on 2024-09-21 19:28:59.
I'm at my wits end here. I have the following nginx.conf server block:
server {
listen 80;
server_name myapp.com;
location /platform/_next/ {
alias /usr/share/nginx/html/_next/;
index index.html;
}
location /platform/static/ {
alias /usr/share/nginx/html/static/;
index index.html;
}
location ^~ /platform/tutorial {
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;
proxy_redirect off;
}
location ~ "^/platform/threads/([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})" {
proxy_pass http://localhost:3000$requesturi;
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_redirect off;
}
location /platform/ {
alias /usr/share/nginx/html/_next/server/app/;
index index.html;
try_files $uri $uri/ index.html;
}
}
All these urls work great. However, my problem is when trying myapp.com/platform WITHOUT the trailing forward slash.
myapp.com/platform/ works fine. myapp.com/platform returns 404.
I've tried everything. I've tried a location = /platform block, I've tried adding a rewrite at the top of my server block to add trailing forward slashes, nothing I try changes the result. What in the world is going on here?