我有一個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
配置中做到這一點。