Target Group 443 Gives Health Checks Failed With These Codes: [502]
I wanted to deploy a Laravel website to amazon, so I did the following steps:
- Deployed the Laravel App using Elastic Beanstalk
- Configured Route:53 A instance to point to the Ip of Ec2
- Created Application Load Balancer with two listeners one at 80 and one at 443
- Created 2 target groups Tg80 and Tg443 and designate the listener respectively
Note that Tg443 has a valid SSL certificate
Changed the security group of the Ec2 to be the Load balancer's one
- Changed the A instance in Route:53 to be the load balancer's
**Results: **
The site works perfectly on port 80 with http, same for health check, and I can acces the site normally from any browser
The site returns [502 Bad Gateway] on https:443
In (After ssh to instance) /var/log/httpd/error_log I have the following error
/var/www/html/.htaccess: RewriteCond: bad flag delimiters
So, I tried, According to the link enforce-https-laravel:
To configure
.htaccess
in the laravel app as said in the link, refreshed everything `php artisan config:cache, retried health check but Same ResultsThe I deleted
.htaccess
and configuredapp/Providers/AppServiceProvider.php
:
use Illuminate\Contracts\Routing\UrlGenerator;
public function boot(UrlGenerator $url)
{
if(env('ENFORCE_SSL', false)) {
$url->forceScheme('https');
}
}
- And added
ENFORCE_SSL=true
in.env
and thenphp artisan config:cache
as said in the same link it is a newer way than.htaccess
.
But Same Results
I don't know what to do net or how to fix this.I want to be able to access the site with ssl. Please Help. Thank you.
Answer
Based the comments, the issue was that the health checks were set to use HTTPS between ALB and EC2. However, since ALB terminates the SSL connections, all traffic between ALB and EC2 is in HTTP, not HTTPS.
Therefore, the solution to not working health checks was to use HTTP for them, rather then HTTPS.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms