0
我想让nginx提供我的Rails应用中/ public/system/articles/images中的所有图像。我已经尝试过 位置/系统{0}允许所有; }nginx提供了某个目录中的所有文件
当我放入my_site.com/public/system/picture.png时,会返回Rails 404页面(与nginx 404页面相反,或者是我真正以后的图像)。
这是我目前的conf文件:
upstream varnish {
server localhost:6081;
}
server {
listen 80;
server_name my_site.com;
location ~* \.(ico|css|js|gif|jpe?g|png)\?[0-9]+?$ {
expires max;
break;
}
root /home/my_site/my_site/current/public;
location /system {
allow all;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-AI-App "my_site";
proxy_pass http://varnish;
}
#root /home/my_site/my_site/current/public;
location/{
# all IP addresses are listed here:
allow all;
try_files $uri @app;
}
}
把它可能是你的正则表达式这是错误的。我只是试过这个。 'file =“/system/articles/images/bar.png”; file =〜/\.(ico|css|js|gif|jpe?g|png)\?[0-9]+?$/ => nil' –
如果我禁用该位置指令,则会得到相同的错误。 –
但是,你想用它来为静态图像提供指令吗?如果是这样,你将需要修复正则表达式而不是禁用它。 –