【发布时间】:2020-07-24 14:37:52
【问题描述】:
我们的 Rails 应用程序在 puma/nginx 上运行 在 NGINX 配置的下方。
我想要实现的是,当请求 URL 为 http://example.com 时,它将提供来自 /public/cached_pages/index.html 的静态缓存文件,并且在所有其他情况下,它的工作方式就像现在这样传递请求到rails/puma
upstream rails {
server unix:///var/www/html/cms/shared/sockets/puma.sock;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Cache-Control "public";
expires 2d;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_pass http://rails;
}
【问题讨论】:
标签: ruby-on-rails nginx nginx-config