我似乎无法找出导致此问题的原因,并且我尝试过多次更改启用站点的文件。
/ etc / nginx / sites-enabled / {site}:
server {
listen 80 default_server;
server_name {site};
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/{site};
}
location /media/ {
root /root/{site}/{site}/media;
}
location / {
include proxy_params;
proxy_pass http://unix:/root/{site}/{site}.sock;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/{site}/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/{site}/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
/ root / {site} / {site} /settings.py(媒体设置):
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
答案 0 :(得分:0)
根表示在向路径添加任何内容之前的基本目录。所以这个:
location /media/ {
root /root/{site}/{site}/media;
}
将尝试从/root/{site}/{site}/media/media/...whatever.css提供媒体服务