Eri*_*son 28 codeigniter nginx amazon-web-services docker amazon-elastic-beanstalk
在我登录并设置cookie后,我得到错误502.当我读取日志时,我收到错误:
014/05/17 01:54:43 [error] 11013#0: *8 upstream sent too big header while reading response
header from upstream, client: 83.248.134.236, server: , request: "GET /administration
HTTP/1.1", upstream:
Run Code Online (Sandbox Code Playgroud)
经过一些快速的谷歌搜索,我发现:http: //developernote.com/2012/09/how-i-fixed-nginx-502-bad-gateway-error/
我想尝试将fastcgi_buffers和fastcgi_buffer_size设置为不同的值.但是如何在amazon elasticbeanstalk中设置nginx变量?
nginx服务器在我的docker实例之前.
Mat*_*man 34
亚马逊实际上建议编辑nginx部署文件的暂存版本.有几个位于/tmp/deployment/config/,一个用于编辑一般的'http'上下文,然后一些用于配置服务器的不同方面.
我想将缓存功能附加到默认代理服务器,因此我编写了一个.ebextensions要替换的配置文件#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf,然后/etc/nginx/conf.d在部署期间将其复制到该文件中.如果文件足够简单,你可以内联文件,但是我把它放在S3中,以便不同的应用程序将其拉下并使用它.这是配置文件:
commands:
01-get-nginx-conf-file:
command: aws s3 cp s3://<bucket-name>/custom-nginx.conf /home/ec2-user
container_commands:
01-replace-default-nginx-config:
command: mv -f /home/ec2-user/custom-nginx.conf /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
Run Code Online (Sandbox Code Playgroud)
sve*_*iss 22
我还需要修改nginx配置.
/etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker.conf)并重新启动nginx服务(service nginx restart).ebextension配置示例如下.ebextensions/01modify_nginx.config:
container_commands:
copy:
command: "cp .ebextensions/01rewrite_nginx_config.py /opt/elasticbeanstalk/hooks/appdeploy/enact/"
make_exe:
command: "chmod +x /opt/elasticbeanstalk/hooks/appdeploy/enact/01rewrite_nginx_config.py"
Run Code Online (Sandbox Code Playgroud)
现在这对我的项目很有效(这里是您可以看到它的动作源).
jse*_*nck 20
扩展Elastic Beanstalk nginx配置的另一种方法是在.ebextensions目录中创建一个文件,例如nginx.config使用以下内容命名:
files:
"/etc/nginx/conf.d/000_my_config.conf":
content: |
upstream nodejsserver {
server 127.0.0.1:8081;
keepalive 256;
}
server {
listen 8080;
location / {
proxy_pass http://nodejsserver;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /myconfig {
proxy_pass http://my_proxy_pass_host;
}
}
Run Code Online (Sandbox Code Playgroud)
/etc/nginx/conf.d/000_my_config.conf是将在Elastic Beanstalk EC2实例上创建的文件名.默认情况下,此配置位于文件中/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf.因此,如果您使用000作为前缀,则可以保证您的配置将首先考虑在内.
内容已从默认的nginx配置中复制(/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf再次),然后使用我自己的配置进行自定义.
Sun*_*ahi 11
截至2022年2月2日更新
较新的方法是在 zip 包的根目录中创建一个“.platform”文件夹,并将 nginx.conf 文件添加到“./platform/nginx/nginx.conf”,如果在该位置找到该文件,eb 引擎应该交换该文件。
有关详细信息,请参阅此处:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.migration-al.html
另请参阅此处的“反向代理配置”>“配置 nginx”部分。
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

更简洁的方法(如果您在Elastic Beanstalk上使用Java或Go平台)是在.ebextensions中的子文件夹中包含您希望的更改的nginx .conf文件:
您现在可以在.ebextensions/nginx文件夹中放置nginx.conf文件以覆盖Nginx配置.您还可以将配置文件放在.ebextensions/nginx/conf.d文件夹中,以便将它们包含在平台提供的Nginx配置中.
| 归档时间: |
|
| 查看次数: |
38448 次 |
| 最近记录: |