I am setting up an environment with a django application (askbot opensource project), gunicorn and nginx. With nginx and gunicorn in different docker containers.
This is my nginx configuration.
server {
listen 80;
location /static {
alias /askbot/static;
}
location /m {
alias /askbot/static;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://askbot:8080/;
}
}
If I run the django app on debug mode, everything is ok, I can go through nginx and I see how nginx is only invoking gunicorn for the dynamic content, and the static content is resolved locally.
But, when I run the django application with debug false, nginx does not revolve the static content, and if I see the source code for the web page, I can see all the paths for the static content have changed, using somethign like "/m/CACHE...". I guess this is the reason why nginx cannot resolve the static content anymore.
For example, when using debug mode equals true, this is one fragment of the html source code.
<link rel="stylesheet" href="/m/CACHE/css/9275d0e5b87f.css" type="text/css" /> <link href="//fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin-ext" rel="stylesheet" type="text/css" /> <link href="//fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=cyrillic-ext" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="/m/default/media/jslib/modernizr.custom.js?v=1"></script> <script type="text/javascript">
And when running with debug equals false, the same fragment is like.
<link href="/m/default/media/style/style.css?v=1" rel="stylesheet" type="text/css" /> <link href="/m/default/media/fa-4.3.0/css/font-awesome.css?v=1" rel="stylesheet" type="text/css" /> <link href="/m/default/media/bootstrap/css/bootstrap.css?v=1" rel="stylesheet" type="text/css" /> <link href="//fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin-ext" rel="stylesheet" type="text/css" /> <link href="//fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=cyrillic-ext" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="/m/default/media/jslib/modernizr.custom.js?v=1"></script> <script type="text/javascript">
I have been going around this for two days, could anyone explain to me why is that happening and how can be fixed ?, configuring nginx on a different way, or disabling django to have that behaviour.
Thanks in advance, Esteban Collado