5

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;
      }
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372

1 Answers1

6

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

Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • @dryleaf You can make new question with details of your EB setup and any relevant error messages. – Marcin Dec 07 '20 at 05:47
  • this does not work for me. I've created a file in my app root dir: .platform/nginx/nginx.conf with the context copied from AWS /etc/nginx/nginx.conf plus added `client_max_body_size 500M;` I do not see any error in `/var/log/eb-engine.log` However when deployment is done there is not client_max_body_size property set in /etc/nginx/nginx.conf – aldm Feb 03 '23 at 07:58
  • @aldm So why not make a question specific to your use-case? – Marcin Feb 03 '23 at 07:59
  • I just edited the question, sorry it went to early :) – aldm Feb 03 '23 at 08:01
  • I temporarily solve it by adding client_max_body_size to `/opt/elasticbeanstalk/config/private/nginx/nginx.conf.template` but this won't work for all environments, so it would be better if I can make .platforms/nginx/nginx.conf works :) – aldm Feb 03 '23 at 08:08
  • Sorry my fault :) By default all dirs starting with . were exclude from app bundle, meaning that .platform and even .ebextensions dirs were not at all added to app bundle. I needed to change zip command in my GitHub Action for deploying to AWS to this: `zip deploy.zip -r * .[^.]* --exclude=**node_modules** --exclude=**postmarket_medias**` – aldm Feb 04 '23 at 07:05