I use Docker, Nginx, Django, ... and this is the result when hitting "/admin/" django page.
As you can see:
- 3 css files have been downloaded but they have no effect
- Request Headers include "Accept: text/css, ..."
- Response Headers include "Content-Type: text/html"
- Also, I get "Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://192.168.99.100/static_files/admin/css/base.css" in the console.
I have seen numerous similar? posts and have tried the respective ways to import mime types, since that seems to be the problem. Nothing was the solution.
Here is a relevant part of my "/etc/nginx/conf.d/default.conf" file within Ngingx Docker Container:
server {
listen 80;
server_name 192_168_99_100;
.
.
.
location /static/ {
autoindex off;
alias /static_files/;
}
location ^~ /admin/ {
autoindex off;
include uwsgi_params;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://192.168.99.100:8000; #without trailing slash
proxy_read_timeout 900;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
Μaybe some useful info:
- static_files is a volume that django container fills with their static files and it is being shared as folder "/static_files/" between several containers such us nginx.
- django container listens to port 8000
Here is my "/etc/nginx/nginx.conf":
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
As you can see, it contains:
- "include /etc/nginx/mime.types;" <- this was the most common suggested solution
- "include /etc/nginx/conf.d/*.conf;" <- that's how my previous file "/etc/nginx/conf.d/default.conf" is being included
What steps must I take now?
UPDATE


/static_files/is a top level directory and not at/usr/share/nginx/html/static_files? Yourtext/htmlfile is probably/index.htmlas thelocation /block is the only one that matches the requested URI. - Richard Smith