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

Problem with static files #13

Closed
alexandervidyaev opened this issue Oct 12, 2022 · 2 comments
Closed

Problem with static files #13

alexandervidyaev opened this issue Oct 12, 2022 · 2 comments

Comments

@alexandervidyaev
Copy link

Hello. I have problem with static files like this:
image
image
and other stuff. But admin console works perfectly with css:
image

Idk why, but nginx works right with admin console, there is it logs:
image

Site logs:

image

Nginx config:


upstream main {
    server web:8000;
}

server {

    listen 80;
    location / {
        proxy_pass http://main;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        client_max_body_size 100M;
    } 
    location /static/ {
        alias /home/app/web/staticfiles/;
    }
}

Docker-compose


version: '3.8'

services:
  web:
    build: .
    #command: /bin/sh -c "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --no-input && gunicorn main.wsgi:application --bind 0.0.0.0:8000"
    command: /bin/sh -c "gunicorn main.wsgi:application --bind 0.0.0.0:8000"
    volumes:
      - ./staticfiles/:/usr/src/app/staticfiles/
    expose:
      - 8000
    ports:
      - 8000:8000
    depends_on:
      - db
  db:
    image: postgres:14.0
    volumes:
      - ./postgres_data/:/var/lib/postgresql/data/
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=database
    ports:
      - 5432:5432
  nginx:
    build: ./nginx
    ports:
      - 80:80
    volumes:
      - ./staticfiles/:/home/app/web/staticfiles/
    depends_on:
      - web
@Yawan-1
Copy link
Owner

Yawan-1 commented Oct 12, 2022

Hello @alexandervidyaev , I have seen the logs and there is nothing wrong in your Nginx configuration. The problem is in the CSS's serving URL which I used of stack over flow's production CSS and They changed their production CSS so my App's CSS is broke with it, Take a look at it. so your static is loading fine but the CSS is broke. But I have plans to fix this in few days.

@alexandervidyaev
Copy link
Author

Thanks dude for your fast answer!
GL further :)

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

2 participants