【问题标题】:Where does Elastic Beanstalk store the nginx configuration file? And how does one modiy it?Elastic Beanstalk 将 nginx 配置文件存储在哪里?以及如何修改它?
【发布时间】:2019-01-18 18:40:08
【问题描述】:

在我的 Elastic Beanstalk 实例中,我可以选择 Nginx 作为我的实例前面的代理。

但是,它没有说明配置文件(即/nginx/conf.d/proxy.conf)可能在哪里,也没有说明如何对其进行更改。

我发现some documentation 提到了 conf 文件,但没有提供有关如何实时查看或对其进行更改的信息。

有谁知道如何阅读和编辑 Elastic Beanstalk 应用程序上的 nginx conf?

【问题讨论】:

    标签: amazon-web-services nginx configuration amazon-elastic-beanstalk


    【解决方案1】:

    通常您不想更改 Elastic Beanstalk 实例上的文件。该环境的优点是您可以根据需要启动新实例,而无需触摸它们。

    您可以使用ebextensions 方法对 Elastic Beanstalk 机器进行大量自定义。基本上,这是一个脚本和文件结构,可让您更改环境。请注意,最好的调试方法是在机器中启用 SSH 并观察启动脚本在做什么。我觉得亚马逊没有很好地记录这个过程,观察它的作用仍然是最简单的方法。

    我使用 Java Elastic Beanstalk 并且必须将代理的端口从 5000 更改为 8080。我有一个文件,在我的环境中,它替换了现有的代理文件。在我的 Elastic Beanstalk 分发文件的 .ebextensions/nginx/conf.d/elasticbeanstalk 中,我将以下内容包含为 00_application.conf

    #
    # default is 404 - no need to allow anything else
    #
    location / {
        return 404;
    }
    
    #
    # this is our default url path prefix
    #
    location /integration {
        proxy_pass          http://127.0.0.1:8080;
        proxy_http_version  1.1;
    
        proxy_set_header    Connection          $connection_upgrade;
        proxy_set_header    Upgrade             $http_upgrade;
        proxy_set_header    Host                $host;
        proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    }
    

    这是针对仅公开 /integration 的 REST 服务。关键是我必须从登录机器中获取初始文件,以查看我的环境是如何配置的。根据您选择的 Elastic Beanstalk 环境类型,您的设置可能会有所不同。比如在Java世界里,有Tomcat类型和Java应用类型,两者的配置是很不一样的。

    【讨论】:

      猜你喜欢
      • 2015-11-27
      • 2014-12-01
      • 2013-07-14
      • 2020-09-29
      • 2017-04-01
      • 2015-02-23
      • 1970-01-01
      • 1970-01-01
      • 2015-12-13
      相关资源
      最近更新 更多