Page 1 of 1

Configuration persistence across deployments

Posted: Thu Jan 23, 2025 8:28 am
by Fgjklf
Elastic Beanstalk deployments replace EC2 instances, eliminating any manual changes. To ensure that the configuration persists:

Include the .platform/nginx/conf.d/elasticbeanstalk/01-rewrite.conf file in your repository.
Check that it is not listed in .gitignore and push it to version control: git add .platform/nginx/conf.d/elasticbeanstalk/01-rewrite.conf

git commit -m "Add Nginx configuration for redirection to public/ directory"

3. Configuration validation
After performing a deployment, verify leads for commercial real estate that the Nginx server is using the correct directory:
sudo cat /etc/nginx/conf.d/elasticbeanstalk/01-rewrite.conf

The file should show the line:
If it does not appear, make sure the .platform file was correctly included in the deployment.

Result
With this configuration, requests are correctly redirected to the index.php controller inside the public/ directory , resolving 404 errors and ensuring that the Symfony application works correctly.

Common problems and solutions
Problem 1: 404 errors on friendly routes
Symptoms
Symfony friendly routes, such as /order/invoice/{id} , generate 404 errors, while the main page ( / ) loads correctly.

Cause
The default Elastic Beanstalk configuration with Nginx does not redirect requests to the main index.php controller , which is required to process Symfony friendly routes.

Solution
To ensure that Nginx correctly redirects requests:

1. Validate URL Rewriting Configuration Make sure the .platform/nginx/conf.d/elasticbeanstalk/01-rewrite.conf file includes: location / {
root /var/
try_files $uri /index.php$is_args$args;
}

2. Persist the configuration Include this file in version control and verify its presence after deployment with:

sudo cat /etc/nginx/conf.d/elasticbeanstalk/01-rewrite.conf

3. Restart Nginx if necessary If the changes are not applied automatically:

sudo service nginx restart

Result
Friendly routes correctly redirect to index.php , eliminating 404 errors.

Problem 2: Empty JWT tokens
Symptoms The /auth
endpoint responds with an empty token ( { "token": "" } ) even when the credentials are correct.

Cause
Elastic Beanstalk replaces EC2 instances on every deployment, removing manually generated JWT keys, preventing token signing.