【发布时间】:2017-02-10 20:16:24
【问题描述】:
我有一个在localhost:9001 上运行的supervisord 服务器。
我正在尝试在localhost/supervisord 提供服务。
nginx 配置是这样的:
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /tmp/nginx.pid;
#daemon off;
events {
worker_connections 1024;
}
http {
# MIME / Charset
default_type application/octet-stream;
charset utf-8;
# Logging
access_log /var/log/nginx/access.log;
# Other params
server_tokens off;
tcp_nopush on;
tcp_nodelay off;
sendfile on;
upstream supervisord {
server localhost:9001;
}
server {
listen 80;
client_max_body_size 4G;
keepalive_timeout 5;
location ^~ /stylesheets {
alias /Users/ocervell/.virtualenvs/ndc-v3.3/lib/python2.7/site-packages/supervisor/ui/stylesheets;
access_log off;
}
location ^~ /images {
alias /Users/ocervell/.virtualenvs/ndc-v3.3/lib/python2.7/site-packages/supervisor/ui/images;
access_log off;
}
location /supervisord {
# Set client IP / Proxy IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
# Set host header
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://supervisord/;
}
}
}
在添加^~ /images 和^~ /stylesheets 位置之前,页面返回502 Bad Gateway。
通过上述配置,我可以访问localhost/supervisord,但页面上缺少 CSS。
我看到浏览器中的 css / 图像已正确加载:
但我在浏览器控制台中看到一条错误消息,这似乎是罪魁祸首:
localhost/stylesheets/supervisor.css 在浏览器中的 mimetype 显示为 octet-stream 而不是 text/css。
localhost:9001/stylesheets/supervisor.css 在浏览器中的 mimetype 显示为正确的text/css。
我该如何解决这个错误?
我考虑过动态重写静态文件的 mimetype,但我不是 nginx 方面的专家,也不知道如何从 nginx 配置中做到这一点。
【问题讨论】:
标签: nginx supervisord