Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serving of /static in production is not working. #59

Closed
mmichealjroberts opened this issue May 16, 2019 · 3 comments
Closed

Serving of /static in production is not working. #59

mmichealjroberts opened this issue May 16, 2019 · 3 comments

Comments

@mmichealjroberts
Copy link

The serving of static assets in the production deployment is not working.

The call to anything in /static/ returns a 404 Nginx Error.

@mmichealjroberts
Copy link
Author

I have done the usual python manage.py collectstatic --no-input command on run.

Tried:

$ docker-compose -f production.yml run nginx ls /usr/src/app/static

Output:

$ ls: cannot access /usr/src/app/static: No such file or directory

@mmichealjroberts
Copy link
Author

$ docker-compose -f production.yml run nginx ls /www/static

Returns:

$ admin

@mmichealjroberts
Copy link
Author

mmichealjroberts commented May 16, 2019

The fix was to change the location alias to point to the same as in the production.yml file, i.e., /www/static.

Change sites-enabled/django-project to:

server {

    listen 80;
    server_name example.org;
    charset utf-8;

    location /static {
        alias /www/static;
    }

    location / {
        proxy_pass http://web:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant