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

查看:204
本文介绍了如何在运行docker实例的amazon弹性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设置为不同的值。
但是我如何在亚马逊弹性豆串中的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 restart )。

  2. 在这个nginx配置文件被写入后,你需要执行这个脚本,这是正常的ebextensions执行之后。这是没有文件的,但Evan分享了如何做到这一点 here :本质上你使用将脚本复制到具有在适当时间执行的钩子的目录中的扩展。

  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 config是 .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弹性beanstalk中更改nginx配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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