Skip to content

Instantly share code, notes, and snippets.

@softaliens
Created September 17, 2017 08:00
Show Gist options
  • Save softaliens/94c474ca94e64c3f40677331c323e132 to your computer and use it in GitHub Desktop.
Save softaliens/94c474ca94e64c3f40677331c323e132 to your computer and use it in GitHub Desktop.
nginx config
upstream unicorn_staging.thecrg.org {
server unix:/srv/www/crg/shared/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name staging.thecrg.org crg rails-app2;
access_log /var/log/nginx/staging.thecrg.org.access.log;
keepalive_timeout 5;
client_max_body_size 1024m;
root /srv/www/crg/current/public/;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
proxy_pass http://unicorn_staging.thecrg.org;
break;
}
}
location ^~ /assets/ {
location ~* "^.*?\.(eot)|(ttf)|(woff)|(woff2)$" {
add_header Access-Control-Allow-Origin *;
}
gzip_static on;
expires max;
add_header Cache-Control public;
}
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /srv/www/crg/current/public/;
}
location = /start {
return 301 http://thecrg.org/?utm_source=Print&utm_medium=Magazines&utm_campaign=CTandCCPrintAds;
}
}
server {
listen 443;
server_name staging.thecrg.org crg rails-app2;
access_log /var/log/nginx/staging.thecrg.org.https.access.log;
keepalive_timeout 5;
client_max_body_size 1024m;
root /srv/www/crg/current/public/;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header Host $http_host;
proxy_redirect off;
# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
proxy_pass http://unicorn_staging.thecrg.org;
break;
}
}
location ^~ /assets/ {
location ~* "^.*?\.(eot)|(ttf)|(woff)|(woff2)$" {
add_header Access-Control-Allow-Origin *;
}
gzip_static on;
expires max;
add_header Cache-Control public;
}
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /srv/www/crg/current/public/;
}
location = /start {
return 301 http://thecrg.org/?utm_source=Print&utm_medium=Magazines&utm_campaign=CTandCCPrintAds;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment