Nginx defaults to /usr/share/nginx/html

Solution 1:

In Nginx if there is no matching location for a uri then it usually defaults to looking in /usr/share/nginx/html/ (likewise with OpenResty /usr/openresty/nginx/html/). So it would seem that it's not matching one of your URIs and falling back to the default location.

The simplest way to find out the default location is to run (as commented by @Snidhi the -V option now supersedes the -h option for this purpose):

nginx -V

The default location may be found by taking the path shown in response at --prefix and appending 'html' to it.

You can see this behaviour if you just create a minimal nginx.conf file without any location entries and run it with debug mode on:

# Put in file /tmp/nginx-test.conf
error_log /dev/stderr debug;
daemon off;

events {
    worker_connections 1024;
}
http {
    server {
        listen 8080;
    }
}

Then run the server:

sudo nginx  -c /tmp/nginx-test.conf

And you'll see that all requests (e.g. in another window:)

curl http://127.0.0.1:8080/test

attempt to open() files from /usr/share/nginx/html/

Solution 2:

You have two distinct server blocks there. One serves your WordPress web site on HTTP. The other was created by certbot and serves nothing on HTTPS. You can add the relevant configuration to the second server block, or combine them, to solve the immediate problem.

Unfortunately certbot is not very good at writing web server configurations, and I always recommend people put together the nginx configurations themselves and run certbot in certonly webroot mode. I've posted a sample configuration in another answer on this site, which you may find useful.