Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Nginx and Passenger for my rails application. I want to use proxy cache to cache my pages. However, every request go direct to my rails application. I don't know what wrong with my configuration. Below is my configuration:

user www-data;
worker_processes  1;

events {
    worker_connections  1024;

http {
    passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15;
    passenger_ruby /usr/bin/ruby1.8;
    passenger_max_pool_size 6;
    passenger_max_instances_per_app 1;
    passenger_pool_idle_time 0;
    rails_spawn_method conservative;
    include       mime.types;
    default_type  application/octet-stream;

    server_names_hash_bucket_size 512;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_http_version 1.0;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/plain text/css text/javascript application/javascript    application/json application/x-javascript text/xml application/xml application/xml+rss;

    proxy_cache_path  /var/www/cache/webapp levels=1:2 keys_zone=webapp:8m max_size=1000m inactive=600m;
    include vhosts/*.conf;

    include /opt/nginx/conf/sites-enabled/*;

    root    /var/www;

server {
    server_name localhost;
    root /var/www/yoolk_web_app/public;   # <--- be sure to point to 'public'!
    passenger_enabled on;
    rails_env development;
    passenger_use_global_queue on;


server {
    listen 80;
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  Host       $host;

    error_page 503 http://$host/maintenance.html;

    location ~* (css|js|png|jpe?g|gif|ico)$ {
    root /var/www/web_app/public;
    expires       max;

location / {
    proxy_cache webapp;
    proxy_cache_valid  200 10m;

#More Location

share|improve this question

Try to determine right passenger_spawn_method option in your nginx config file to cache any application code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.