如何在运行 docker 实例的 amazon elastic beanstalk 中更改 nginx 配置 [英] How to change nginx config in amazon elastic beanstalk running a docker instance

查看:41
本文介绍了如何在运行 docker 实例的 amazon elastic beanstalk 中更改 nginx 配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我登录并设置 cookie 后,我收到错误 502.当我阅读日志时,我收到错误:

After i login and the cookie is set I get error 502. When i read the log i get the error:

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:

经过一些快速的谷歌搜索后,我发现:http://developernote.com/2012/09/how-i-fixed-nginx-502-bad-gateway-error/

After some fast googling i found: http://developernote.com/2012/09/how-i-fixed-nginx-502-bad-gateway-error/

我想尝试将 fastcgi_buffers 和 fastcgi_buffer_size 设置为不同的值.但是如何在 amazon elasticbeanstalk 中的 nginx 上设置变量?

and I want to try to set fastcgi_buffers and fastcgi_buffer_size to a different value. But how do i set variable on nginx in amazon elasticbeanstalk?

nginx 服务器在我的 docker 实例之前.

The nginx server is before my docker instance.

推荐答案

我还需要修改 nginx 配置.

I also needed to modify the nginx configuration.

  1. 创建一个修改nginx配置的脚本(可能你想要/etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker.conf)并重启nginx服务(service nginx重启).
  2. 您需要在编写此 nginx 配置文件后执行该脚本,也就是在执行正常的 ebextensions 之后.这是无证的,但埃文分享了如何做到这一点这里:基本上你使用一个 ebextension,用于将脚本复制到带有钩子的目录中,并在适当的时间执行.
  1. Create a script that modifies the nginx configuration (probably you want /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker.conf) and restarts the nginx service (service nginx restart).
  2. You need to execute that script after this nginx config file is written which is after normal ebextensions are executed. This is undocumented, but Evan shared how to do this here: essentially you use an ebextension to copy the script into a directory with hooks that gets executed at the proper time.

一个示例 ebextension 配置是 .ebextensions/01modify_nginx.config:

An example ebextension config is .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"

这现在对我的项目运行良好(这里是您可以看到它运行的源代码).

This is working nicely now for my project (here is the source where you can see it in action).

这篇关于如何在运行 docker 实例的 amazon elastic beanstalk 中更改 nginx 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆