0

nginx がルート ドメインでキャッシュされた index.html ページを提供していないことに気付きました。

例) http://dev.website/up を提供する必要/rails_app/public/cache/index.htmlがありますが、デフォルトではファイルを提供する rails app になります

http://dev.website/same/page事実上、ルート URL と同じページですが、としてキャッシュされ/rails_app/public/cache/same/page.htmlます。できます。

基本的に、キャッシュにヒットしていない唯一の URL はルート URL です。これが私の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;
}
4

0 に答える 0