6

In my EC2 Ubuntu 18.04 instance, I have created an django.conf file at /etc/nginx/sites-available

The .conf file looks like so :

server {
        listen 80;
        server_name *[url_name]*;

        location / {
                include proxy_params;
                proxy_pass http://unix:/home/ubuntu/ZTS-JOBCARDS/app.sock;
        }

}

and when I ran sudo nginx -t before trying to link the files to /etc/nginx/sites-enabled/ the result came back positive

However, after I had linked the files like so: sudo ln -s django.conf /etc/nginx/sites-enabled/

The nginx -t command returns the following error ;

nginx: [emerg] open() "/etc/nginx/sites-enabled/django.conf" failed (40: Too many levels of symbolic links) in /etc/nginx/nginx.conf:62 nginx: configuration file /etc/nginx/nginx.conf test failed

What would cause this error and are their any guides to fixing it ?

KyleStranger
  • 163
  • 1
  • 1
  • 4

1 Answers1

8

You have linked django.conf back to itself. There's no data in the file, just a reference to itself.

This command,

ln -s django.conf /etc/nginx/sites-enabled/    # Wrong

creates a symbolic link in /etc/nginx/sites-enabled called django.conf, pointing to django.conf. You can see this with ls -l /etc/nginx/sites-enabled/django.conf.

What you intended was this, which creates a symbolic link in /etc/nginx/sites-enabled called django.conf pointing to the relative location, ../sites-available/django.conf

cd /etc/nginx/sites-enabled && ln -s ../sites-available/django.conf

If you want to avoid changing your current directory, wrap the pair of commands in brackets

( cd … && ln … )
roaima
  • 107,089
  • 14
  • 139
  • 261