0

I am trying to serve CSS and other static files on my django app using NGINX server. So I tried to configure it. Here is my /etc/nginx/sites-enabled/mydomain:

server {
    listen 80;
    server_name redpillers.net;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/limited/REDPILLERS;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/limited/REDPILLERS/redpillers.sock;
    }

    location /static/ {
       alias /home/limited/REDPILLERS/static/;
    }

}

But when I restart the service I got an error in the error logs file:

2019/05/22 07:26:44 [emerg] 11589#11589: duplicate location "/static/" in /etc/nginx/sites-enabled/mydomain:15

2 Answers 2

1
server {
    listen 80;
    server_name redpillers.net;

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/limited/REDPILLERS/redpillers.sock;
    }

    location /static/ {
       alias /home/limited/REDPILLERS/static/;
    }

}

You have location /static/ two times in configuration. Just remove one.

Sign up to request clarification or add additional context in comments.

Comments

0

please remove the second /static/ location and keep the first one So the ultimate config:

server {
    listen 80;
    server_name redpillers.net;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/limited/REDPILLERS;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/limited/REDPILLERS/redpillers.sock;
    }

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.