在AWS Elastic Beanstalk中自定义Nginx配置

Gra*_*ham 12 ruby-on-rails nginx amazon-web-services amazon-elastic-beanstalk

我正在Ruby 2.0/Puma实例上运行rails应用程序,我正在尝试自定义nginx配置.我需要增加允许的请求大小以允许文件上传.我发现了其他一些帖子让我把它添加到我的.ebextensions中:

files:
  "/etc/nginx/conf.d/proxy.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      client_max_body_size 70M;
Run Code Online (Sandbox Code Playgroud)

这确实按预期创建了文件,但是在我手动重启nginx之前它似乎没有用.因此,我试图找到一种方法,用.ebextensions命令重新启动nginx,但没有取得任何成功.有没有人知道用.ebextensions重新启动nginx的方法,或者知道更好的方法来解决这个问题?

Gra*_*ham 12

我发现了一种在部署后使用未记录的技术运行部署后脚本的方法来重启nginx的方法.我把它添加到我的.ebextensions:

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/03_restart_nginx.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      service nginx restart
Run Code Online (Sandbox Code Playgroud)


Ari*_*Ari 5

要重新加载 nginx 配置,您可以使用 container_commands

来自http://www.infoq.com/news/2012/11/elastic-beanstalk-config-files

container_commands 键允许您为容器执行命令。它们在设置应用程序和 Web 服务器并提取应用程序之后,但在部署应用程序之前运行。container_commands 按名称按字典顺序处理。

container_commands:
  01_reload_nginx:
    command: "service nginx reload"
Run Code Online (Sandbox Code Playgroud)