1

I have the same issue as 404 and the answers is correct and when I add

location / {
    try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
}

The problem is solved. How can I do such a thing in .ebextensions?

yasin lachini
  • 5,188
  • 6
  • 33
  • 56

1 Answers1

1

To customize nginx on Amazon Linux 2 you should use .platform/nginx/conf.d/, not .ebextensions. The .ebextensions` were used for Amazon Linux 1.

The AWS docs provide an example of how to add configuration options to nginx:

~/workspace/my-app/
|-- .platform
|   `-- nginx
|       `-- conf.d
|           `-- myconf.conf
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I want to change php.conf in cd /etc/nginx/conf.d/elasticbeanstalk – yasin lachini Jul 13 '20 at 07:32
  • can I do that by .platform/nginx/conf.d/php.conf? – yasin lachini Jul 13 '20 at 07:33
  • @yasinlachini You can try. You can even fully overwrite entire nginx settings as explained in the docs if this is need. If this does not work, you can update your question with more details to help better identify the solution. – Marcin Jul 13 '20 at 07:36
  • @yasinlachini [One of the answers](https://stackoverflow.com/a/61978311/248823) in the questions you've liked also shows how to overwrite entire nginx settings on AL2. – Marcin Jul 13 '20 at 07:44
  • 1
    the problem solved after I add .platform/nginx/conf.d/php.conf – yasin lachini Jul 13 '20 at 07:51
  • Could you please explain what you mean by "add .platform/nginx/conf.d/php.conf"? I've been struggling with the same problem and have not found a way to have this line added automatically via deployment (and I really don't want to override the entire configuration just to change one thing). – MikelG Aug 26 '21 at 03:52
  • @MikelG I would suggest making new question with details specific to your issue and use case. – Marcin Aug 26 '21 at 03:58
  • My question is exactly this... How can I add the configuration line automatically during deployment? I have tried what you suggested every which way and it does not work. When I vim into PHP.conf and add the lines manually, it works fine. Making another question would be a duplicate. – MikelG Aug 26 '21 at 11:19
  • In hopes of getting more attention, I've followed your suggestion @Marcin. https://stackoverflow.com/questions/68940725/elastic-beanstalk-nginx-extending-configuration – MikelG Aug 26 '21 at 14:47