I am using Nginx 0.7.64, Passenger 2.2.9, Rails 2.3.5. I have a page caching directory installed in / public / cache, and I would like to be able to serve cached pages on request via HTTP, but always click on the Rails application on request via HTTPS.
The main part of my configuration looks like this:
server {
listen 80;
server_name website.com www.website.com;
proxy_set_header X-Forwarded-Proto http;
root /home/deploy/website/current/public;
passenger_enabled on;
if (-f $document_root/cache/$request_filename.html) {
rewrite (.*) $document_root/cache/$1.html break;
}
}
server {
listen 443;
server_name website.com www.website.com;
root /home/deploy/website/current/public;
passenger_enabled on;
proxy_set_header X-Forwarded-Proto https;
ssl on;
ssl_certificate /home/deploy/website/shared/ssl/www.website.com.combined.crt;
ssl_certificate_key /home/deploy/website/shared/ssl/www.website.com.key;
}
I expect that when I ask website.com/about, I should submit /public/cache/about.html, but instead I got to the Rails server (the tail of the log shows it).
I think that I may have the wrong slash (and not seeing $document_rootin most examples), I also tried all of the following options, none of which work:
if (-f cache$request_filename.html) {
rewrite (.*) cache$1.html break;
}
if (-f /cache$request_filename.html) {
rewrite (.*) /cache$1.html break;
}
if (-f cache/$request_filename.html) {
rewrite (.*) cache/$1.html break;
}
if (-f /cache/$request_filename.html) {
rewrite (.*) /cache/$1.html break;
}
root, passenger_enabled location /, . , passenger_enabled . $uri. , - !
, XML api, ( , .html), public/cache/index.html, website.com. , - .:)
!
if (-f $document_root/cache$request_uri.html)
, ! , , !
if (-f $document_root/cache$request_uri.html) {
rewrite (.*) /cache$1.html break;
break;
}
URL /cache/cache/about.html.html Rails, . , ! /cache$1, /cache/cache/about Rails, $1.html /about.html.html Rails, $1 /about, Rails . , . Nginx , Passenger ?