can helpme?
My application in django does not load the css when I use gunicorn + nginx below I have permission error:
2023/07/05 16:29:51 [error] 18862#18862: *1 open() "/home/victor/helpme/tickets/static/css/style.css" failed (13: Permission denied), client: 192.168.0.106, server: 192.168.0.113, request: "GET /static/css/style.css HTTP/1.1", host: "192.168.0.113", referrer: "http://192.168.0.113/ticket_list/"
My socket file:
[Unit] Description=gunicorn helpme socket [Socket] ListenStream=/run/gunicorn_helpme.sock [Install] WantedBy=sockets.target~
~
~
My Service File:
[Unit]
Description=gunicorn daemon
Requires=gunicorn_helpme.socket
After=network.target
[Service]
User=victor
Group=www-data
WorkingDirectory=/home/victor/helpme
ExecStart=/home/victor/helpme/venv/bin/gunicorn
--access-logfile -
--workers 3
--bind unix:/run/gunicorn_helpme.sock
ticket_system.wsgi:application
[Install]
WantedBy=multi-user.target
Nginx:
ps auxf | grep nginx
victor 18883 0.0 0.0 6476 2308 pts/0 S+ 16:34 0:00 | _ grep --color=auto nginx
root 18860 0.0 0.0 55196 1716 ? Ss 16:29 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 18861 0.0 0.2 55864 5596 ? S 16:29 0:00 _ nginx: worker process
www-data 18862 0.0 0.2 55864 5596 ? S 16:29 0:00 _ nginx: worker process
Sites-enabled
server {
listen 80;
listen [::]:80;
index index.html index.htm index.nginx-debian.html index.php;
server_name 192.168.0.113;
location /static/ {
root /home/victor/helpme/tickets;
}
location /media {
alias /home/victor/helpme/tickets/;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn_helpme.sock;
}
location ~ /.ht {
deny all;
}
location ~ /. {
access_log off;
log_not_found off;
deny all;
}
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
access_log off;
#access_log /var/log/nginx/temp.otaviomiranda.com.br-access.log;
error_log /var/log/nginx/vm-error.log;
}
Folder Project Permissions
drwxrwxrwx 7 root root 4,0K jul 5 16:26 helpme
I asked pro chat gpt he raised questions about selinux, but he is inactive! still the CSS presents error to read the files.
2
Answers
This happens to me a lot as well. this is the snippet you can use:
Your static/media location definitions are miss configured right now. You’ve given full access to allow anyone to browse your tickets directory because you stop the path at the tickets folder instead of going one deeper to the static/media files. Even if you fix the permission issue you should still have issues without fixing those paths.