Existing solutions did't help me so I must be missing something else.
So I'm trying to setup a website with Apache 2.4/CentOS 7 behind a AWS Network load balancer.
I'm using this in httpd.conf to rewrite HTTP->HTTPS which is also considered the right way to achieve HTTPS only behind a load balancer by AWS.
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{SERVER_NAME}/$1 [L,R=permanent]
where SERVER_NAME
is the DNS name of my server which resolves to the IP address of the load balancer.
https://%{HTTP:Host}/
was tried unsuccessful as well.
Without this, accessing the server is possible without problems (except that it's possible to use HTTP of course).
As the load balancer is the encryption endpoint for the client, I'm only listening on port 80 on the webserver. That is the intended way of implementing by AWS.
Using this however, the server will endlessly redirect my request until the browser gives up. And it also happens when trying to connect with HTTPS initially.
The debug-level log output of Apache is not showing any errors except that the request is timing out and the load balancer logs are also not very helpful. But maybe you can make a sense out of it.
I was also thinking of SELinux causing trouble but it is set on permissive. So it shouldn't actually do anything.
Apache access_log: https://textuploader.com/10cjh
Apache error_log: https://textuploader.com/10cjx
Load balancer: https://textuploader.com/10cjg
Any help is highly appreciated.
So the solution is to use an Application Load Balancer instead of a Network Load Balancer.