The original post: /r/nginx by /u/outdoorszy on 2025-03-03 17:54:42.

Running debian and nginx v1.26.3 , I created /usr/share/nginx/static directory path and put a cv.docx file in there. I want to serve that file (and other file extensions in the future), tried the official docs, blogs and get a 404 error when trying to load https://domain.com/resume/cv.docx (ideal path) or domain.com/cv.docx. What am I doing wrong?

server {
    root /usr/share/nginx/html;
    server_name domain.com www.domain.com;

    listen [::]:444 ssl ipv6only=on; # managed by Certbot
    listen 444 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    location /static {
    try_files /$uri =404;
    }

}

server {
    if ($host = www.domain.com) {
    return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = domain.com) {
    return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 81 default_server;
    listen [::]:81 default_server;
    server_name domain.com www.domain.com;
    return 404; # managed by Certbot
}

anon@domain:~$ ls /usr/share/nginx/static/
total 28K
drwxr-xr-x 2 root root 4.0K 2025-03-03 09:14 .
drwxr-xr-x 5 root root 4.0K 2025-03-03 09:13 ..
-rwxr-xr-x 1 anon anon  17K 2025-03-03 09:13 cv.docx
anon@domain:~$