Created
August 15, 2014 10:41
-
-
Save we4tech/b1728e1cc34ac3c59240 to your computer and use it in GitHub Desktop.
Rails4 and Angularjs with Nginx + Proxy cache
This file contains hidden or 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 puma { | |
server 127.0.0.1:8080 fail_timeout=0; | |
} | |
proxy_cache_path /home/of/all/evil/stuffs/as/shared/tmp/cache/nginx levels=1:2 keys_zone=api-cache:10m max_size=1000m inactive=200m; | |
# HTTP server | |
# | |
server { | |
listen 0.0.0.0:80; | |
server_name somedomain.com; | |
root /home/of/all/evil/stuffs/as/current/public; | |
access_log /home/of/all/evil/stuffs/as/current/log/access.log; | |
error_log /home/of/all/evil/stuffs/as/current/log/error.log; | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
location ^~ /ng-assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
location ^~ /templates/ { | |
expires -1; | |
add_header Cache-Control no-cache; | |
} | |
location ^~ /api/v1/ { | |
proxy_ignore_headers "Set-Cookie" "Cache-Control"; | |
proxy_cache api-cache; | |
proxy_cache_valid any 6h; | |
proxy_cache_use_stale error timeout invalid_header updating; | |
add_header X-NC Yes; | |
proxy_pass http://puma; | |
} | |
try_files $uri/index.html $uri @puma; | |
location @puma { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://puma; | |
proxy_connect_timeout 300; | |
proxy_read_timeout 300; | |
} | |
gzip on; | |
gzip_http_version 1.0; | |
gzip_disable "MSIE [1-6]\.(?!.*SV1)"; | |
gzip_buffers 4 16k; | |
gzip_comp_level 2; | |
gzip_min_length 0; | |
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
gzip_proxied expired no-cache no-store private auth; | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment