I am migrating to Elastic Beanstalk and was not able to make changes to the nginx file, or even increment a new file. All configurations per AWS documentation did not work. So I did it as follows:
/.ebextesions -> 01_laravel_nginx.config:
files:
"/opt/elasticbeanstalk/support/conf/laravel.conf":
mode: "000644"
owner: root
group: root
content: |
location / {
try_files $ uri $ uri / /index.php?$query_string;
gzip_static on;
}
/.ebextesions -> 02_install_nginx.config:
container_commands:
01_runmyshellscript:
command: "sudo ln -s /opt/elasticbeanstalk/support/conf/laravel.conf /var/proxy/staging/nginx/conf.d/elasticbeanstalk"
After performing this configuration, the same information as in the /var/proxy/staging/nginx/conf.d/elasticbeanstalk directory will be in the /etc/nginx/conf.d/elasticbeanstalk directory.
Is there any better way?
2
Answers
I was just trying to add one more conf, instead of changing what already existed by default. I tried to perform this configuration as follows:
But I didn't create. have to create all the files?
The proper way to setup nginx on EB environments using Amazon Linux 2 (AL2) is through
.platform/nginx/conf.d/
as shown in the docs. Or if you want to fully overwrite the mainnginx.conf
you should provide its custom version using.platform/nginx/nginx.conf
.