问题
I am deploying my Laravel application to AWS ElasticBeanstalk. I have deployed it. Now, I am trying to override "/etc/nginx/conf.d/elasticbeanstalk/php.conf" file using .platform folder.
I created .platform/etc/nginx/conf.d/elasticbeanstalk/php.conf file right inside the project's root folder. Then I put in the configuration content.
Then I deploy my application executing "be deploy" command. But the Nginx config file is not overridden. What is wrong with my config and how can I get it working?
I tried using .ebextensions too creating a config file with the following content. The file is not just created.
files:
/etc/nginx/conf.d/elasticbeanstalk/laravel.conf:
mode: "000755"
owner: root
group: root
content: |
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
回答1:
The nginx
config file you are trying to set is used in Amazon Linux 1 (AL1).
For AL2, the nginx
config files should be provided (aws docs) using:
.platform/nginx/conf.d/
or if you want to overwrite main nginx
config file, use
.platform/nginx/nginx.conf
Thus, you can try the following file .platform/nginx/conf.d/laravel.conf
with content of:
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
If it does not work, you can inspect nginx logs in /var/log
or nginx config folder to check if the file is correctly placed in nginx config folder.
Solution I used
I used this and it worked.
.platform/nginx/conf.d/elasticbeanstalk/laravel.conf
来源:https://stackoverflow.com/questions/62901090/aws-elasticbeanstalk-overriding-nginx-config-using-platform-is-not-working