加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

amazon-web-services – 为什么我得到ElasticBeanstalk :: ExternalInvo

发布时间:2020-05-23 01:43:26 所属栏目:Nginx 来源:互联网
导读:我的应用程序构建在RubyOnRails上,并使用乘客部署为弹性beanstalk应用程序,我正在尝试将标头添加到nginx服务器并重新启动它,这是我的配置文件,来自aws弹性beanstalk的.ebextensions文件夹中的脚本:packages: yum: nginx: [] files: /etc/ngin

我的应用程序构建在RubyOnRails上,并使用乘客部署为弹性beanstalk应用程序,我正在尝试将标头添加到nginx服务器并重新启动它,这是我的配置文件,来自aws弹性beanstalk的.ebextensions文件夹中的脚本:

packages: 
    yum:
        nginx: [] 

files:
    "/etc/nginx/conf.d/webapp.conf" :
        mode: "000644"
        owner: root
        group: root
        content: |
            server {

                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;
                }

            }

# This reloads the server,which will both make the changes take affect and makes sure the config is valid when you deploy
container_commands:
  01_reload_nginx:
    command: "sudo service nginx reload"

但是我收到了这个错误:

[2017-12-13T06:23:48.635Z] ERROR [17344] : Command CMD-AppDeploy failed!
[2017-12-13T06:23:48.635Z] INFO  [17344] : Command processor returning results: 
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"container_command 01_reload_nginx in .ebextensions/01_elastic_beanstalk_webapp.config failed. For more detail,check /var/log/eb-activity.log using console or EB CLI","returncode":7,"events":[]}]}

/var/log/eb-activity.log:

[2017-12-13T06:23:48.584Z] INFO  [17344] - [Application update fix-command-nginx-reload-hope@2/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_myapp_website/Command 01_reload_nginx] : Starting activity...
[2017-12-13T06:23:48.619Z] INFO  [17344] - [Application update fix-command-nginx-reload-hope@2/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_myapp_website/Command 01_reload_nginx] : Activity execution failed,because:  (ElasticBeanstalk::ExternalInvocationError)


[2017-12-13T06:23:48.619Z] INFO  [17344] - [Application update fix-command-nginx-reload-hope@2/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_myapp_website/Command 01_reload_nginx] : Activity failed.

虽然如果我ssh到实例并执行sudo服务nginx重新加载它将正常执行..
任何的想法?

编辑

$cat /proc/version
Linux version 4.9.43-17.39.amzn1.x86_64 (mockbuild@gobi-build-64011) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Fri Sep 15 23:39:41 UTC 2017

部署命令:

eb deploy my-app -v

请求资产的标题:

Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/x-javascript
Date: Fri,24 Aug 2018 11:03:50 GMT
ETag: W/"12cd8ea0-20db3"
Last-Modified: Mon,31 Dec 1979 04:08:00 GMT
Server: nginx/1.12.1
Transfer-Encoding: chunked
Via: 1.1 8cc9957dff77c27e9931ab0aaf344ec9.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 0NlE-FiGgzczadHYeK7HMMsDsGRmaB8Sefvo89phHWw3LSx01t5rgQ==
X-Cache: Miss from cloudfront

缺少标题:

   access-control-max-age: 3000
   age: 48214

服务器上的更新conf文件

$cat /etc/nginx/conf.d/webapp.conf
server {

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

    location /public {
      alias /var/app/current/public;
      gzip_static on;
      gzip on;
      expires max;
      add_header Cache-Control public;
      add_header 'Access-Control-Allow-Origin' '*';
    }

}

编辑

service nginx configtest结果:

$sudo service nginx configtest
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
最佳答案 命令:“sudo service nginx reload”不是必需的,因为NGINX服务在每次成功部署后自动重启.您可以从配置文件中删除它.

您可能会遇到CDN服务到期的延迟,请尝试刷新缓存或直接对EB网址进行测试.

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读