我有一个supervisord
服务器上运行localhost:9001
。 我正在尝试在localhost/supervisord
处提供。Nginx的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
。
该浏览器中的mimetype为localhost:9001/stylesheets/supervisor.css
它显示为正确的text/css
。
我该如何解决这个错误?
我想过动态地重写静态文件的MIME类型,但我不是nginx
的专家,也不知道如何从nginx
配置中做到这一点。