Last active
August 29, 2015 14:02
-
-
Save jackbit/a31a024f077c29c2acba to your computer and use it in GitHub Desktop.
application config for nginx and pagespeed
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
upstream app_upstream { | |
server unix:/home/user/app_folder/current/tmp/sockets/app.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name domain-name.com www.domain-name.com; | |
root /home/user/app_folder/current/public; | |
try_files $uri /system/maintenance.html @app_upstream; | |
pagespeed on; | |
pagespeed FileCachePath /home/user/app_folder/current/public; | |
location @app_upstream { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-NginX-Proxy true; | |
proxy_redirect off; | |
proxy_pass http://app_upstream; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
#limit_req zone=one burst=15; | |
access_log /dev/null; | |
error_log /home/user/app_folder/current/log/nginx.error.log; | |
} | |
location ~ \.(php)$ { | |
deny all; | |
} | |
location ~ ^/(assets|images|javascripts|stylesheets|swfs|system|uploads|fonts)/ { | |
expires 1w; | |
proxy_hide_header Set-Cookie; | |
proxy_ignore_headers Set-Cookie; | |
proxy_set_header Cookie ""; | |
add_header Cache-Control public; | |
add_header Cookie ""; | |
} | |
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; } | |
location ~ "^/ngx_pagespeed_static/" { } | |
location ~ "^/ngx_pagespeed_beacon$" { } | |
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; } | |
location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; } | |
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; } | |
location /pagespeed_console { allow 127.0.0.1; deny all; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment