Django Static Files #1981
Unanswered
EfraimGENC
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Same problem, is there a solution? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Don't forget to link your Django project's static/media folder to the NPM container. The locations you define in NPM can only be accessed in this way. Mount static folder on docker compose fileservices:
npm_app:
image: 'jc21/nginx-proxy-manager:latest'
container_name: npm_app
restart: unless-stopped
ports:
...
environment:
...
volumes:
- ./data/npm/data:/data
- ./data/npm/letsencrypt:/etc/letsencrypt
# HERE MOUNTING STATIC FILES ON YOUR NPM CONTAINER TO ACCESS AS ALIAS
- ./path/of/your/django/media:/data/django/media
- ./path/of/your/django/static:/data/django/static
... Official Then you can configurate like:
Thats it! BONUS:There are many bots that attack WordPress because it is the most common CMS in the world. In order for your Django project to be less affected by these, you can add the following settings to return 404 to the addresses that these bots frequently attack, before the request reaches your Django project.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm publishing my django project as docker container with these settings below:
Scheme:
http
Forward Hostname / IP:
my_django_container_name
Port:
8000
It works fine. Thanks for NPM :)
However, I need to publish/show my static files. My static file folder paths are:
/home/apps/my_django/staticfiles
/app/staticfiles
I tried both of paths above with
alias
tag inCustom Nginx Configuration
like this:but I'm getting
404 Not Found openresty
error only.Is there anyone who has idea to fix this?
Thanks for all..
Beta Was this translation helpful? Give feedback.
All reactions