Created
December 5, 2012 15:40
-
-
Save rkmathi/4216677 to your computer and use it in GitHub Desktop.
http://blog.has-key.org/208 - 2. Nginxの設定
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
user {ユーザ名}; | |
worker_processes 4; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 768; | |
} | |
http { | |
## | |
# Basic Settings | |
## | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
server_tokens off; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
## | |
# Logging Settings | |
## | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
## | |
# Gzip Settings | |
## | |
gzip on; | |
gzip_disable "msie6"; | |
## | |
# nginx-naxsi config | |
## | |
#include /etc/nginx/naxsi_core.rules; | |
## | |
# Virtual Host Configs | |
## | |
include /etc/nginx/conf.d/*.conf; | |
} |
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 unicorn_{アプリケーション名} { | |
server unix:/tmp/unicorn_{アプリケーション名}.sock; | |
} | |
server { | |
listen 80; | |
server_name {アドレス}; | |
root /var/www/{アプリケーション名}/current/public; | |
error_log /var/www/{アプリケーション名}/shared/log/nginx_error.log; | |
# for capistrano | |
if (-f $document_root/system/maintenance.html) { | |
return 503; | |
} | |
error_page 503 @maintenance; | |
location @maintenance { | |
rewrite ^(.*)$ /system/maintenance.html last; | |
break; | |
} | |
try_files $uri $uri.html $uri/index.html @unicorn; | |
location ~ ^/(assets|system|images|javascripts|stylesheets)/ { | |
expires max; | |
add_header Cache-Control public; | |
break; | |
} | |
location / { | |
if (-f $request_filename) { break; } | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_pass http://unicorn_{アプリケーション名}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment