前提・実現したいこと
Rails, Nginx + ubuntuの環境で本番でサービスをスタートさせるためにサーバーの設定をしています。
NginxやUbuntuの設定はあまりちゃんとやったことがなく、サーバー上でRailsを起動させる際に、Rails s だと起動するのですが
ruby
1rails s -e production -d
とバックグラウンドで起動しようとすると502 bad gate wayと出てしまいます。
エラーが出てしまい困っています。
いかrailsアプリのconfig/puma.rbと、/etc/nginx/conf.d/nginx.confファイルの中身です。
nginx.conf
nginx.conf
1 2upstream puma { 3 server unix://home/casino/smartcontract-casino/tmp/sockets/puma.sock; 4} 5 6server { 7 listen 80 default_server; 8 listen [::]:80 default_server; 9 server_name puma; 10 11 location / { 12 proxy_read_timeout 300; 13 proxy_connect_timeout 300; 14 proxy_redirect off; 15 proxy_set_header Host $host; 16 proxy_set_header X-Forwarded-Proto $scheme; 17 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 18 19 proxy_pass http://puma; 20 } 21} 22
ruby
1# Puma can serve each request in a thread from an internal thread pool. 2# The `threads` method setting takes two numbers: a minimum and maximum. 3# Any libraries that use thread pools should be configured to match 4# the maximum value specified for Puma. Default is set to 5 threads for minimum 5# and maximum; this matches the default thread size of Active Record. 6# 7threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8threads threads_count, threads_count 9 10# Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11# 12#port ENV.fetch("PORT") { 3000 } 13 14# Specifies the `environment` that Puma will run in. 15 16environment ENV.fetch("RAILS_ENV") { "development" } 17 18# Allow puma to be restarted by `rails restart` command. 19plugin :tmp_restart 20 21app_root = File.expand_path("../..", __FILE__ ) 22bind "unix://#{app_root}/tmp/sockets/puma.sock"
あなたの回答
tips
プレビュー