我使用Nginx和Passenger作为我的rails应用程序.我想使用代理缓存来缓存我的页面.但是,每个请求都直接发送到我的rails应用程序.
我不知道我的配置有什么问题.
以下是我的配置:
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 {
listen 127.0.0.1:3008;
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;
server_name webpage.dev;
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_pass http://127.0.0.1:3008/;
proxy_cache webapp;
proxy_cache_valid 200 10m;
}
#More Location
}
最佳答案
原文链接:https://www.f2er.com/nginx/435431.html