In my Elastic Beanstalk instance, I am able to select Nginx to be the proxy in front of my instance.
However, it gives no indication of where the config file (i.e. /nginx/conf.d/proxy.conf
) might be, nor how to make changes to it.
I found some documentation that mentions the conf file, but offers no information on how to see it live or make changes to it.
Does anyone know how to read and edit the nginx conf on an Elastic Beanstalk application?
答案 0 :(得分:1)
通常,您不想更改Elastic Beanstalk实例上的文件。该环境的优点是您可以根据需要启动新实例,而无需触摸它们。
您可以使用ebextensions方法对Elastic Beanstalk机器进行大量自定义。基本上,这是一个脚本和文件结构,使您能够更改环境。请注意,尽管最好的调试方法是将SSH启用到计算机中,并注意启动脚本的作用。我觉得Amazon尚未很好地记录此过程,而观察它仍然是最简单的方法。
我使用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应用程序类型,两者的配置非常不同。