I'm trying to setup Google Load Balancer and couldn't get it work. It produces either 502 or 302 error.
Wanting to direct www to non-www, http to https.
This is my rewrite rule
SetEnvIf X-Forwarded-Proto https HTTPS=on
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs"
Include "/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"
<IfModule mod_proxy.c>
ProxyPass /.well-known !
</IfModule>
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^localhost
RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ http://%1$1 [R=permanent,L]
<VirtualHost _default_:443>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^localhost
RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ https://%1$1 [R=permanent,L]
Google Load Balancer has only 1 backend service. Backend is configured for HTTP and frontend is HTTPS with 60s timeout.
- The instance is accessible via both instance's IP and load balancer's IP
- www to non-www is not working.
- Http gives a 404 error.
- https gives a 502 / 302 error.
Are the rewrite rules all wrong?