AWSのEC2にデプロイしようとして、Pumaとnginxの設定をしたことがなくどうすればいいかわからず困ってます。
操作はsshで入ってしております。
これをしないとrailsのviewを表示できないので、お力を貸して頂きたいです。
当方、初心者でして必要事項の記入漏れや受け答えがうまくできないかもしれないですけどよろしくお願い致します。
・求める成果
Railsのviewを表示させたい
・実行できないと思われる原因
nginxと接続されていないようでrailsの起動後にブラウザでwex01.cloud24.jp:3000と打っても応答がなくタイムアウトします。
rails側は何もログが出ていないです。
wex01.cloud24.jpだけならnginxの"Welcome nginx..."indexページが表示されます。
・開発環境
ubuntu:18.04
ruby:2.5.1
rails:5.2.0
nginx:1.12.1
Puma:3.12.0
Railsアプリ"webex"パス
/home/"ユーザ名"/workspace/working/webex
URL:wex01.cloud24.jp
###config/puma.rb
# Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # environment ENV.fetch("RAILS_ENV") { "development" } app_root = File.expand_path("../..", __FILE__) bind "unix://#{app_root}/tmp/sockets/puma.sock" # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). # # workers ENV.fetch("WEB_CONCURRENCY") { 2 } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write # process behavior so workers use less memory. # # preload_app! # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart
試したこと
$ sudo curl -v http://localhost:3000/
- Trying 127.0.0.1...
- TCP_NODELAY set
- connect to 127.0.0.1 port 3000 failed: 接続を拒否されました
- Failed to connect to localhost port 3000: 接続を拒否されました
- Closing connection 0
curl: (7) Failed to connect to localhost port 3000: 接続を拒否されました
###nginx.conf
user appusr; worker_processes 1; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 1024; } http { upstream backend { server unix:/home/kkawahara/workspace/working/webex/tmp/sockets/puma.sock max_fails=3 fail_timeout=10s; keepalive 15; } include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; include /etc/nginx/conf.d/*.conf; index index.html index.htm; server { listen 80; server_name localhost; root /usr/share/nginx/html; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location ~ .php$ { proxy_pass http://backend; } } }