Created
August 24, 2010 17:55
-
-
Save jpinnix/547977 to your computer and use it in GitHub Desktop.
Help nginx+passenger serve static index pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Help nginx+passenger serve static index pages | |
# Site specific config | |
server { | |
listen 80; | |
server_name domain.com; | |
index index.html; | |
access_log logs/appname.access.log; | |
error_log logs/appname.error.log; | |
# Check for index pages first | |
location / { | |
root /home/username/appname/current/public; | |
try_files $uri /$uri/index.html @passenger; | |
} | |
# Okay, there isn't a static index file, so go to passenger | |
location @passenger { | |
root /home/username/appname/current/public; | |
proxy_set_header X-Forwarded-Proto http; | |
passenger_enabled on; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nginx.conf | |
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
passenger_root /usr/local/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-2.2.15; | |
passenger_ruby /usr/local/ruby-enterprise-1.8.7-2010.02/bin/ruby; | |
include mime.types; | |
default_type application/octet-stream; | |
sendfile on; | |
keepalive_timeout 65; | |
fastcgi_intercept_errors on; | |
server { | |
server_name _; | |
return 444; | |
} | |
include /usr/local/nginx/conf/sites-enabled/*; | |
} |
Thanks a bunch for this. I just switched from apache -> nginx and this was just what I needed!
I have a pull request here that fixes this in passenger: phusion/passenger#15
Unfortunately it's been ignored -- haven't been able to even get any feedback about why it isn't accepted.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Apache+Passenger, the serving of index pages "just works". This definitely required a lot of digging and almost no one had any ideas. Finally on #linode IRC, someone suggested using try_files and there was an example on ServerFault (http://j.mp/cYHGQh) of how to accomplish this for cached pages. But I was just wanting it to work for static pages.