Score:1

Redirecting Error with google load balancer

mx flag

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?

Tatikonda vamsikrishna avatar
in flag
Is your issue resolved?if yes, can you post the procedure you've followed as Solution and accept it.
Score:1
tv flag

As per my understanding you are trying to configure http to https in a external HTTP(S) Load Balancer, it seems that you set up a URL Rewrite rules in apache instead redirects in GCP, based on the traffic management for HTTP(S) Load Balancers, redirects includes the capability to redirect all HTTP requests to HTTPS requests, here’s an example to set up http-https redirect

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.