an example from railsgirlschina.com:
(notice : root for location ~ ^/assets/ is : /opt/app/siwei/rails_girls_cn/shared; , but not : /opt/app/siwei/rails_girls_cn/shared/assets
server {
listen 80;
server_name www.railsgirlschina.com railsgirlschina.com www.railsgirlsbeijing.com railsgirlsbeijing.com;
charset utf-8;
location / {
proxy_pass http://rails_girls_site;
proxy_redirect default;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
}
location ~ ^/assets/ {
root /opt/app/siwei/rails_girls_cn/shared;
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
}
upstream rails_girls_site{
server localhost:3560;
server localhost:3561;
}