3

I would like to force the redirect from http to https so that when the user enters: http://example.com he gets redirected to https://example.com.

I've tried everything described in this post and I even had it working, but I have no Idea what has changed, but it's not working anymore.

I've tried several options for the RewriteCond like !https, =http, ^http$ and the only outcome I can produce is, that the EB health check is redirected, which causes even https://example.com to have an empty response if I use !https.

<VirtualHost *:80>
     <Proxy *> 
         Order Allow,Deny
         Allow from all
     </Proxy>
     ProxyPass / http://localhost:8080/ retry=0
     ProxyPassReverse / http://localhost:8080/
     ProxyPreserveHost on
     LoadModule rewrite_module modules/mod_rewrite.so
     RewriteEngine On
     RewriteCond %{HTTP:X-Forwarded-Proto} !https
     RewriteCond %{HTTP_USER_AGENT} !ELB-HealthChecker
     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

I've got the following listener: Loadbalancer Listener

I'm connecting to my ec2 instance directly via ssh to test the configurations in /etc/httpd/conf.d/elasticbeanstalk, so I test, I restart the server sudo httpd -k restart and nothing changes. I've even logged the rewrite via:

RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 3

and I can see, that admin/health is checked, but nothing else. There are also no errors in the elasticbeanstalk-error.log. The weird thing is, that I had it working and I was convinced that I had just made the changes, that I've described above, but I can't get it to work again and it's really driving me crazy!


SOLVED:

So I've solved it: the problem was not the configuration file but the Loadbalancer Listener, I needed the listener for HTTP as the following:

enter image description here

luetti_87
  • 31
  • 4

0 Answers0