I am hosting a react web app in the Azure Web App. My app is containerized and is getting deployed via Docker Compose:
I am using Nginx as a web server to launch this app.
For my nginx.conf
, I am confused why the removing of $uri/
is causing a 404 Not Found
error. I have my index.html
placed within the /usr/share/nginx/html/
directory.
nginx.conf.template:
server {
listen 80;
location ${SUB_PATH} {
alias /usr/share/nginx/html/;
try_files $uri index.html;
}
}
/etc/nginx/conf.d# cat default.conf
server {
listen 80;
# If SUB_PATH is "/", this becomes 'location /'
# IF SUB_PATH is "/test/", this becomes 'location /test/'
location /test/ {
alias /usr/share/nginx/html/;
try_files $uri index.html;
}
}
If I remove the $uri/
I am getting the following error:
2025-01-29T15:09:11.861827644Z: [ERROR] 2025/01/29 15:09:11 [error] 13#13: *3 open() "/etc/nginx/htmlindex.html" failed (2: No such file or directory), client: 172.16.121.1, server: , request: "GET / HTTP/1.1", host: "custom-domain.azurewebsites"
/etc/nginx/html
index.html
file within /usr/share/nginx/html/
?