Any Aws Eb Laravel Route Getting 404 Not Found Nginx/1.16.1

Error 404 even though routes exist - AWS, Laravel

Everything was from the .htaccess file. I added AllowOverride All and everything is ok now!

elasticbeanstalk get 404 when I use nginx

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

AWS Elasticbeanstalk overriding Nginx config using .platform is not working

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

AWS Beanstalk config file not executing at deployment

One apparent issue is the use of wrong extensions for your nginx config files.

The file should be *.conf, not *.config as shown in the docs.

A reason why your .platform folder is ignored, could be that you maybe have it in your .gitignore or .ebignore files.

Please note that even if you fix the extension, the configuration itself may be still incorrect, which I can't verify.

/api route not reachable after installing Laravel application to Amazon Elastic Beanstalk

Like I was thinking, nginx is not configured properly by default. After I've added

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

everything worked.

I am leaving this topic if anyone else has the same problem.



Related Topics



Leave a reply



Submit