'Nginx 403 while accessing static files in docker volumes
I am trying to serve static files in docker volumes for my Django project. Nginx is able to access the files(403) error. I tried to solve this in different ways like updating the file permission. Nginx I am installed in a normal way without a container and Django, Postgres database is running in a container
Nginx configuration
server {
listen 80;
server_name 139.59.73.115;
location / {
include proxy_params;
proxy_pass http://127.0.0.1:8000;
}
location /static {
root /var/lib/docker/volumes/m3-mobiles_m3-mobiles-assets/_data/;
}
}
Solution 1:[1]
I think need changed:
server {
listen 80;
listen [::]:80;
server_name 139.59.73.115;
rewrite ^ https://$host$request_uri? permanent;
location / {
root /var/www/html/;
autoindex on;
}
location ~ /.well-known {
allow all;
}
}
On run docker the containe map your path location: /home/xxxxx/xxxx:/var/www/html/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kopper |