我注意到nginx没有在根域上提供缓存的index.html页面。
ex。)http://dev.website/
应该提供/rails_app/public/cache/index.html
,但默认为提供该文件的rails app
http://dev.website/same/page
实际上与根网址相同,但缓存为/rails_app/public/cache/same/page.html
。它有效。
基本上唯一没有访问缓存的网址是根网址。我知道这与我的nginx配置有关,但是我对nginx知之甚少知道如何修复它。
以下是我的配置片段:
try_files /cache/$uri /cache/$uri.html $uri $uri/index.html $uri.html @ruby;
我确定这部分内容是无关紧要的,有人可以帮我清理一下吗?
编辑:这是我的配置......
server {
listen 80;
server_name pos;
#access_log C:/rails_apps/pos/log/nginx-access.log;
error_log C:/rails_apps/pos/log/nginx-error.log;
root C:/rails_apps/pos/public;
index index.html;
location / {
satisfy any;
allow 192.168.0.0/25;
deny all;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 120;
proxy_connect_timeout 120;
expires max;
add_header Cache-Control must-revalidate;
if ($request_method != GET) {
proxy_pass http://pos;
}
if ($request_uri ~ .*.search=.*) {
proxy_pass http://pos;
}
try_files /cache/$uri /cache/$uri.html $uri $uri/index.html $uri.html @ruby;
}
location ~ ^/(assets)/ {
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
location @ruby {
proxy_pass http://pos;
}
}
upstream pos {
server 127.0.0.1:3000;
}