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
PHP & MySQL: Using Group by for Categories
Apple Push Notification with Sending Custom Data
Best Way to Check If a Url Is Valid
Image Upload Storage Strategies
Efficient PHP Auto-Loading and Naming Strategies
What Are the Differences Between "PHP Artisan Dump-Autoload" and "Composer Dump-Autoload"
Strip PHP Variable, Replace White Spaces with Dashes
Cannot Pass Null Argument When Using Type Hinting
Laravel Use Same Form for Create and Edit
PHP Call_User_Func VS. Just Calling Function
Converting Named HTML Entities to Numeric HTML Entities
Query Time Result in MySQL W/ PHP
Read Associative Array from JSON in $_Post
Convert a String Containing a Number in Scientific Notation to a Double in PHP
Using Regular Expressions to Extract the First Image Source from HTML Codes