Created
May 29, 2014 18:36
-
-
Save tomaadland/f1d55ce083f30b131700 to your computer and use it in GitHub Desktop.
nginx config gile
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 cream_shop { | |
server 127.0.0.1:8081; | |
} | |
passenger_pre_start http://localhost:8081; | |
passenger_max_pool_size 20; | |
passenger_pool_idle_time 10; | |
server { | |
listen 8081; | |
root /var/www/apps/cream-shop/current/public; | |
passenger_enabled on; | |
passenger_min_instances 4; | |
access_log /var/log/nginx/passenger.log; | |
error_log /var/log/nginx/passenger-error.log; | |
} | |
server { | |
server_name www.creamclothing.no; | |
rewrite ^(.*) http://creamclothing.no$1 permanent; | |
} | |
server { | |
listen 80 default_server; | |
server_name creamclothing.no; | |
rewrite /admin$ $scheme://$host permanent; | |
access_log /var/log/nginx/cream.log; | |
error_log /var/log/nginx/cream-error.log; | |
# auth_basic "Restricted"; | |
# auth_basic_user_file /var/www/apps/cream-shop/current/public/system/.htpasswd; | |
# Rails isn't interested by default in any other type of request | |
# so deal with them here | |
if ($request_method !~ ^(GET|HEAD|PUT|POST|DELETE|OPTIONS)$ ){ | |
return 405; | |
} | |
# Sort out redirects | |
## If it has come from localhost - dont mess, handy for services running locally | |
if ($host = localhost ) { break; } | |
root /var/www/apps/cream-shop/current/public; | |
# Your favorite error pages | |
error_page 404 /404.html; | |
error_page 422 /422.html; | |
error_page 500 /500.html; | |
# Simple way to serve static content and maintenance page if maintenance page present | |
try_files $uri /maintenance.html @app; | |
location @app { | |
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-Queue-Start "t=${msec}000"; | |
proxy_pass http://cream_shop; | |
proxy_redirect off; | |
limit_req zone=one burst=5; | |
proxy_cache_bypass $http_secret_header; | |
add_header X-Cache-Status $upstream_cache_status; | |
access_log /dev/null; | |
} | |
location ~ ^/(assets|images|javascripts|stylesheets|swfs|system|spree)/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment