Amazon actually recommends editing the staging version of the nginx deployment file. There are several located at /tmp/deployment/config/
, one for editing the general 'http' context, and then a few for configuring different aspects of the server.
I wanted to attach caching functionality to the default proxy server, so I wrote an .ebextensions
config file to replace #etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
, which is then copied over to /etc/nginx/conf.d
during deployment. You can inline the file if its simple enough, but I put mine in S3 so that different applications and pull it down and use it. Here's the config file:
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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…