【发布时间】:2018-04-19 08:33:27
【问题描述】:
我有一个包含几个页面和图像的网站,并且我已经设置了一个 nginx 服务器来处理该网站。当我添加一个位置指令来处理图像时,整个网站并没有显示出来并且看起来很糟糕。
当我的 nginx 文件的底部看起来像这样时,网站看起来很完美:
location = /favicon.ico {
access_log off;
log_not_found off;
}
location = /robots.txt {
allow all;
access_log off;
log_not_found off;
}
location ~ /\. {
deny all;
}
#location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
# proxy_cache sinuscache;
# add_header Pragma public;
# add_header Cache-Control "public";
# expires 1d;
# log_not_found off;
#}
location ~* (\.bak|\.off|\.config|\.exe|\.sql|\.fla|\.psd|\.ini|\.log|\.sh|\.inc|\.swp|\.dist)$ {
deny all;
add_header Pragma public;
add_header Cache-Control "public";
expires -1d;
access_log off;
}
location / {
include /etc/nginx/sites-settings/denyips.conf;
proxy_pass http://127.0.0.1:9099;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache sinuscache;
}
}
当我取消评论时
#location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
# proxy_cache sinuscache;
# add_header Pragma public;
# add_header Cache-Control "public";
# expires 1d;
# log_not_found off;
#}
网站中断。如果我做一个
service nginx configtest
我没有收到任何错误。
【问题讨论】: