Author Topic: Serving static content from folder  (Read 3493 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Serving static content from folder
« on: December 04, 2020, 08:56:27 AM »
Trying to serve Django/postgresql/redis with nginx/gunicorn.

Everything is working correctly except the Nginx conf file for the site. trying to serve static files from a specific folder and it is not being recognized. Any suggestions? I feel like I am missing something obvious and I just need a fresh pair of eyes. Thanks for any help!

server {
   listen ipaddress;   
   server_name myservername;
       location /static/ {
            location ~* \.(css|gif|ico|jpe?g|js[on]?p?|mpe?g|mp3|mp4|wav|woff|eot|svg|txt)$ {
                root /home/myuser/static;
                access_log                off;
                add_header                Cache-Control   "public, must-revalidate, proxy-revalidate";
                add_header                Pragma          "public";
                expires                   365d;
                log_not_found             off;
                tcp_nodelay               off;
                open_file_cache           max=16 inactive=600s; # 10 minutes
                open_file_cache_errors    on;
                open_file_cache_min_uses  2;
                open_file_cache_valid     300s; # 5 minutes
            }
        }

        location / {
            include proxy.inc;
            add_header                X-Proxy-Cache $upstream_cache_status;
            proxy_pass                http://unix:/run/gunicorn.sock;
        }
}