I recently ran into an issue with how /etc/nginx/sites-enabled is used (or not) depending what nginx version you’re running on, or more likely according to this post, whether you’re running nginx on Debian/Ubuntu or the official nginx package.
The difference (which is pretty significant if you’re not expecting it), is that:
- Debian/Ubuntu versions for nginx have sites-enabled included in nginx.conf by default
- The official upstream nginx package does not
What this means is on Debian/Ubuntu, in /etc/nginx/nginx.conf you’ll have this include:
include /etc/nginx/sites-enabled/*;
but it’s missing if you run the upstream nginx package, like what seems to be included in the Docker image nginx:latest.
In my case running the Docker image nginx:latest every GET request was getting a 404 and the only clue was in my error.log each request was attempting to serve files from a default /usr/share/nginx/html folder, which is definitely not what was configured as my root in the config in /etc/nginx/sites-enabled:
open() "/usr/share/nginx/html/[url-request-here] HTTP/1.1" failed (2: No such file or directory)
Once I worked out what the issue was I just added the include line for sites-enabled.