无法在 AWS Elastic Beanstalk、AL2 上加载 Ruby 2.7.4 (Rails 6) 应用程序

问题描述 投票:0回答:1

我们有一个 Rails 应用程序,之前部署在 AWS Elastic Beanstalk 的 Ruby 2.6 平台上。我们必须升级到 Ruby 2.7.4,因为 2.6 平台已被 AWS 弃用。升级后,我们可以看到应用程序已成功部署(从 eb-engine.log 中)...但是,当我点击 EB url (XXXXX.YYYYY.us-east-1.elasticbeanstalk.com) 时,什么也没有出现。我已经验证 nginx 和 puma 都在运行,并且日志也显示健康检查正常。 EB 控制台上的环境指示器也显示为 OK。有关我需要寻找什么来调试此问题的任何提示吗?

另一方面,如果我首先将 EB 的示例 Rails 应用程序部署到环境,然后将我的应用程序上传到该环境,它就会开始正常工作......但是,我不想在没有首先弄清楚为什么我的情况下就进入生产环境我无法通过将应用程序直接部署到新环境来访问该应用程序。任何帮助将非常感激。下面是我的 .ebextensions ginx.config

files:
  "/etc/nginx/conf.d/010_app_server.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      # based on /etc/nginx/conf.d/webapp_healthd.conf
      #
      # and notes from "Getting to Know and Love AWS Elastic Beanstalk Configuration Files (.ebextensions)"
      # (https://medium.com/trisfera/getting-to-know-and-love-aws-elastic-beanstalk-configuration-files-ebextensions-9a4502a26e3c)
      #
      # which suggested taking the approach of including a similar
      # nginx conf file before webapp_healthd.conf, which has the
      # effect of "overriding" the setttings from that file

      upstream my_app_new_upstream {
        server unix:///var/run/puma/my_app.sock;
      }

      log_format healthd_new_name '$msec"$uri"'
                      '$status"$request_time"$upstream_response_time"'
                      '$http_x_forwarded_for';

      server {
        listen 80;
        server_name _ localhost; # need to listen to localhost for worker tier

        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
          set $year $1;
          set $month $2;
          set $day $3;
          set $hour $4;
        }

        access_log /var/log/nginx/access.log main;
        access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd_new_name;

        client_max_body_size 100m;

        set $should_enforce_https 0;
        if ($http_x_forwarded_proto != 'https') {
          set $should_enforce_https 1;
        }
        if ($request_uri ~ ^/pages/health_check$) {
          set $should_enforce_https 0;
        }
        if ($should_enforce_https = 1) {
          return 301 https://$host$request_uri;
        }

        location / {
          proxy_pass http://my_app_new_upstream; # match the name of upstream directive which is defined above
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location /assets {
          alias /var/app/current/public/assets;
          gzip_static on;
          gzip on;
          expires max;
          add_header Cache-Control public;
        }

        location /public {
          alias /var/app/current/public;
          gzip_static on;
          gzip on;
          expires max;
          add_header Cache-Control public;
        }
      }

container_commands:
  010_reload_nginx:
    command: "sudo service nginx reload"

这是我的 puma 配置

# 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.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

bind "unix:///var/run/puma/my_app.sock"
pidfile "/var/run/puma/my_app.sock"

# 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" }

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server 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

nginx amazon-elastic-beanstalk ruby-on-rails-6 puma ruby-2.7
1个回答
0
投票

您的 nginx.conf 路径不正确,对于 覆盖 AL2 上的默认 nginx conf,路径应该是 .platform/nginx/nginx.conf

© www.soinside.com 2019 - 2024. All rights reserved.