-
-
Save tomelam/e77abefb010d1c78f0a4399872c4d6f8 to your computer and use it in GitHub Desktop.
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 zwm_app { | |
# Path to Unicorn SOCK file, as defined previously | |
server unix:/home/rails/zwm/shared/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 443 ssl http2; | |
server_name zwm.org.in; | |
ssl_certificate /etc/nginx/ssl/nginx.crt; | |
ssl_certificate_key /etc/nginx/ssl/nginx.key; | |
root /home/rails/zwm/public; | |
add_header X-uri "$uri"; | |
set $ouri $uri; | |
set $point 0; | |
set $argpoint 0; | |
add_header X-debug-message "Original URI: $ouri" always; | |
#try_files /cached_pages/$uri $uri/index.html; | |
## Index HTML Files | |
if (-f $document_root/cached_pages/$uri/index.html) { | |
set $point 1; | |
rewrite (.*) /cached_pages/$1/index.html break; | |
} | |
## Other HTML Files; works OK with zwm.org.in/forum | |
if (-f $document_root/cached_pages/$uri.html) { | |
set $point 2; | |
rewrite (.*) /cached_pages/$1.html break; | |
} | |
## All | |
if (-f $document_root/cached_pages/$uri) { | |
set $point 3; | |
rewrite (.*) /cached_pages/$1 break; | |
} | |
add_header X-debug-message "URI (possibly rewritten, at point $point, argpoint $argpoint): $uri" always; | |
#try_files $uri/index.html $uri /cached_pages/$uri @zwm_app; | |
try_files $uri @zwm_app; | |
# Ensure requests for pagespeed optimized resources go to the pagespeed handler | |
# and no extraneous headers get set. | |
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { | |
add_header "" ""; | |
} | |
location ~ "^/pagespeed_static/" { } | |
location ~ "^/ngx_pagespeed_beacon$" { } | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
## Cache static web pages. | |
location = /cached_pages/index.html { | |
#if ($args ~ [0-9]+) { | |
expires max; | |
break; | |
#} | |
} | |
location @zwm_app { | |
proxy_pass http://zwm_app; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
} | |
## Cache images, JavaScript, and CSS. | |
#location ~* \.(ico|css|js|gif|jpe?g|png) { | |
# set $argpoint 1; | |
# expires max; | |
# break; | |
#} | |
location /nginx_status { | |
stub_status on; | |
access_log off; | |
allow 127.0.0.1; | |
#deny all; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} | |
root@ruby-rails-2gb-blr1-03:/etc/nginx/sites-enabled# ls -l | |
total 0 | |
lrwxrwxrwx 1 root root 22 Jun 1 15:11 zwm -> ../sites-available/zwm | |
root@ruby-rails-2gb-blr1-03:/etc/nginx/sites-enabled# cat zwm | |
upstream zwm_app { | |
# Path to Unicorn SOCK file, as defined previously | |
server unix:/home/rails/zwm/shared/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 443 ssl http2; | |
server_name zwm.org.in; | |
ssl_certificate /etc/nginx/ssl/nginx.crt; | |
ssl_certificate_key /etc/nginx/ssl/nginx.key; | |
root /home/rails/zwm/public; | |
add_header X-uri "$uri"; | |
set $ouri $uri; | |
set $point 0; | |
set $argpoint 0; | |
add_header X-debug-message "Original URI: $ouri" always; | |
#try_files /cached_pages/$uri $uri/index.html; | |
## Index HTML Files | |
if (-f $document_root/cached_pages/$uri/index.html) { | |
set $point 1; | |
rewrite (.*) /cached_pages/$1/index.html break; | |
} | |
## Other HTML Files; works OK with zwm.org.in/forum | |
if (-f $document_root/cached_pages/$uri.html) { | |
set $point 2; | |
rewrite (.*) /cached_pages/$1.html break; | |
} | |
## All | |
if (-f $document_root/cached_pages/$uri) { | |
set $point 3; | |
rewrite (.*) /cached_pages/$1 break; | |
} | |
add_header X-debug-message "URI (possibly rewritten, at point $point, argpoint $argpoint): $uri" always; | |
#try_files $uri/index.html $uri /cached_pages/$uri @zwm_app; | |
try_files $uri @zwm_app; | |
# Ensure requests for pagespeed optimized resources go to the pagespeed handler | |
# and no extraneous headers get set. | |
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { | |
add_header "" ""; | |
} | |
location ~ "^/pagespeed_static/" { } | |
location ~ "^/ngx_pagespeed_beacon$" { } | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
## Cache static web pages. | |
location = /cached_pages/index.html { | |
#if ($args ~ [0-9]+) { | |
expires max; | |
break; | |
#} | |
} | |
location @zwm_app { | |
proxy_pass http://zwm_app; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
} | |
## Cache images, JavaScript, and CSS. | |
#location ~* \.(ico|css|js|gif|jpe?g|png) { | |
# set $argpoint 1; | |
# expires max; | |
# break; | |
#} | |
location /nginx_status { | |
stub_status on; | |
access_log off; | |
allow 127.0.0.1; | |
#deny all; | |
} | |
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