Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Help nginx+passenger serve static index pages
# Help nginx+passenger serve static index pages
# Site specific config
server {
listen 80;
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;
# 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/*;

This comment has been minimized.

Copy link
Owner Author

jpinnix commented Aug 24, 2010

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 ( of how to accomplish this for cached pages. But I was just wanting it to work for static pages.


This comment has been minimized.

Copy link

ippa commented Aug 30, 2011

Thanks a bunch for this. I just switched from apache -> nginx and this was just what I needed!


This comment has been minimized.

Copy link

stepheneb commented Aug 30, 2011

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
You can’t perform that action at this time.