0

So I know this question has been asked, but I am not sure if my initial setup is right.

I have nginx running to serve my angular 5 files. I have daphne running to serve my channels and django code. But I am not sure how to get my static files from django admin to be served.

nginx is listening on port 80 and daphne on port 8080. So to get my admin i can access http://whatever:8080/admin. The admin interface is there but it doesnt load the css files.

How do i change my nginx to get it to load static files from another port?

Here is what my nginx-conf looks like

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/whatever;

    index index.html index.htm index.nginx-debian.html;

    server_name localhost;

    access_log /home/ubuntu/.../logs/nginx-access.log;
    error_log  /home/ubuntu/.../logs/nginx-error.log;

    location / {
            try_files $uri $uri/ /index.html;
    }

    location /static/ {
            proxy_pass              http://127.0.0.1:8080;
            proxy_set_header        Host             $host;
            proxy_set_header        X-Real-IP        $remote_addr;
            proxy_set_header        X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_redirect off;
            alias /home/ubuntu/.../static/;
    }
}

I am sure the last line is not right, and even the last location block.

Any ideas?

Dale
  • 352
  • 2
  • 15

1 Answers1

0

So i am not sure if this is the best solution but it works for now, installed whitenoise and that serves my static files for admin....

Dale
  • 352
  • 2
  • 15