Nginx docker and symbolic links

Built and run nginx in docker. A small piece of docker compose

volumes:
..

  • ./nginx/sites-available:/etc/nginx/sites-available
  • ./nginx/sites-enabled:/etc/nginx/sites-enabled

The site.conf file is created in the sites-available directory and a symbolic link to sites-enabled is created. An error occurs when starting nginx:

nginx: [emerg] open() “/etc/nginx/sites-enabled/site.conf” failed (2: No such file or directory) in /etc/nginx/nginx.conf:32
nginx exited with code 1

Some more information from the directory sites-enabled:

ls -la
lrwxrwxrwx root root 50 B Fri Nov 8 15:20:58 2024 site.conf ⇒ /opt/nginx/nginx/sites-available/site.conf

As I understand it (or maybe not), the problem is that the link is directed to /opt/nginx… and not to the /etc/nginx/sites-enabled directory.

Read more here: Source link