Created
June 13, 2017 06:52
-
-
Save qqpann/e2aaf2253d4c07e5906b068a368e3e44 to your computer and use it in GitHub Desktop.
Unicorn + Nginxを理解する ref: http://qiita.com/Qiuqiu/items/1b82460bfd0db038e126
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 { | |
# nginxとunicornの連携 | |
# unicorn.rbで設定したunicorn.sockを指定 | |
server unix:{RAILS_PROJECT_ROOT}/tmp/sockets/unicorn.sock; #ソケットはこいつだ!socketsを追加 | |
} | |
server { | |
listen 8081; | |
server_name {PROJECTDOMAIN_FOR_LOCAL}; | |
root {RAILS_PROJECT_ROOT}/public; | |
access_log /usr/local/var/log/nginx/{PROJECT_NAME}_access.log; | |
error_log /usr/local/var/log/nginx/{PROJECT_NAME}_error.log; | |
client_max_body_size 100m; | |
error_page 500 502 503 504 /500.html; | |
try_files $uri/index.html $uri @unicorn; | |
location @unicorn { | |
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; | |
} | |
} |
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
#Unicornのログ出力先を指定 | |
#File.expand_pathはパスを絶対パスに解決するメソッド File.expand_path: https://ruby-doc.org/core-2.2.0/File.html#method-c-expand_path | |
rails_root = File.expand_path('../../', __FILE__) | |
#ワーカー数を指定する | |
worker_processes 2 | |
working_directory rails_root | |
listen "#{rails_root}/tmp/sockets/unicorn.sock" #??「Unicornのプロセスをlistenするアドレストポートを指定」らしいが…;socketsを追加。 | |
pid "#{rails_root}/tmp/pids/unicorn.pid" #pid fileの位置を指定する。pidsを追加。 | |
#ログの出力先を指定 | |
stderr_path "#{rails_root}/log/unicorn_error.log" | |
stdout_path "#{rails_root}/log/unicorn.log" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment