docker, nginx,

Docker and missing sites-enabled in Nginx

May 17, 2023 · 1 min read · Post a comment

It’s not a first time to face any gotchas while building Docker images, especially when dealing with symlinks, mount volumes, permissions, etcetera. So, here are few things to check when dealing with /etc/nginx/sites-enabled directory cannot be found.

Prerequisites

  • Docker
  • Nginx

Solution

#1. Make sure that sites-enabled exists in your directory as a symlink or not, it doesn’t really matter much.

#2. Double-check your Dockerfile or docker-compose.yml file that you got the right volume mapping. For instance, in Dockerfile you should have something like this:

COPY nginx-configs/ /etc/nginx/sites-enabled/

#3. Clear any docker build cache: docker system prune and rebuild your image.

#4. If by any chance you are running a Windows machine, and you are trying to mount symlinks (having sites-enabled as a symlink to sites-available directory), you’ll probably have the files there, so the issue most likely will come from the symlink path, the backslashes (\) if you will. So, either copy the nginx configs to your default /etc/nginx/conf.d directory, or if you need to preserve the directory structure, better get rid of the symlinks and have duplicate files in both sites-available and sites-enabled which is not a good, optimal solution. I mean you could just use the sites-available directory in your nginx.conf file instead of sites-enabled but what’s the point, right?! At last, just buy yourself a Linux or a MacBook Pro workstation :)

Conclusion

In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.