I'm following the guide from this article However, when I link my home.html file in my django app's template folder, it doesn't load the css files and it doesn't understand any of the "{% %}" syntax.
How can I configure my nginx server block to load my django app properly?
My /etc/nginx/sites-available/myonlinefp.com file:
server {
root /home/stelity/myonlinefp/foodpantry/templates/;
index index.html index.htm index.nginx-debian.html home.html;
server_name myonlinefp.com www.myonlinefp.com;
location / {
try_files $uri $uri/ =404;
}
location /media {
alias /home/stelity/myonlinefp/foodpantry/media/;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myonlinefp.com/fullchain.pem; # managed by
Certbot
ssl_certificate_key /etc/letsencrypt/live/myonlinefp.com/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
}
server {
if ($host = www.myonlinefp.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = myonlinefp.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name myonlinefp.com www.myonlinefp.com;
}
Updated, this is the edited file for a reply below:
server {
root unix:://run/gunicorn.sock; server_name myonlinefp.com www.myonlinefp.com; location / { try_files $uri $uri/ =404; } location /media { alias /home/stelity/myonlinefp/foodpantry/media/; } listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/myonlinefp.com/fullchain.pem; # managed byCertbot ssl_certificate_key /etc/letsencrypt/live/myonlinefp.com/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 }
server {
if ($host = www.myonlinefp.com) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = myonlinefp.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; listen [::]:80; server_name myonlinefp.com www.myonlinefp.com; }
server{}block setroottopath/to/sockfileand removeindexbecouse you don't need that else evrything is fine I think