-1

I'm getting very frustrated trying to sort this issue out.

We have an AWS environment that uses SSL certificates at the load balancer. We also have a rewrite rule in httpd.conf that redirects all port 80 traffic onto 443. This environment works perfectly with the current servers, it redirects to 443 as expected and the ELB health check ping works as expected.

The problem we have is that we've lost the server build doc and need to recreate it. When trying to configure a new httpd service on a new amazon linux instance we can't get the existing ELB to to see the instance as available - the ELB health check is not working (this works with the existing instance).

The health check is configured as follows:

HTTPS:443/proxy/login.php

(this is not changed and works with the existing instance)

The ELB listener is setup as follows:

Port 80 -> Port 80

Port 443 -> Port 80 (with registered certificate

We also have the following rules within the httpd.conf of the working server:

<VirtualHost *:80>
RequestHeader set X-Forwarded-Proto "http"

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} !^test. [NC]
RewriteCond %{HTTP_HOST} !^signup. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>

I've added the rule to the new server but no luck. I've even copied the httpd.conf from the working server to the new server and still no luck. What else am I missing on the new server? Any other config files that I need to worry about?

  • 1
    If your health check is using port 443 then you need a listener in your httpd on 443. The health check is internal to the EC2 instance, not as if it's coming from an external source. If your instance is only listening on port 80 then your health check must use port 80. – Matt Houser Jun 17 '15 at 16:35
  • Agree completely - but this setup works without issue with the existing box? I've resolved the issue now by adding an explicit clause no to redirect the health check: RewriteCond %{REQUEST_URI} !^/proxy/login\.php$ – Rob Bennett Jun 17 '15 at 16:45
  • 1
    Is the working server listening on port 443? What if you `curl` the health check url manually directly at the servers? – Matt Houser Jun 17 '15 at 16:47
  • 2
    Health checks cannot be redirected. Returning a redirect on the health check URL will fail the health check. The health check must be 200. – Matt Houser Jun 17 '15 at 17:06

1 Answers1

0

Thanks for all the inputs. I've solved this by adding a condition to the virtualhost section that exludes the redirect to 443 for the:

RewriteCond %{REQUEST_URI} !^/proxy/login\.php$
Diamond
  • 8,791
  • 3
  • 22
  • 37