skip to Main Content

We already tried other solutions on Stack Overflow but they didn’t work for us.

We are having issues while redirecting our Domain url from http to https.

When we hit the http://example.com, it is not getting redirected to https://example.com. We have also set up a Google Managed SSL in the Load Balancer in our Google Cloud Network Service.

We are using the Google Cloud Compute Engine for hosting the website and Google domains for url. Apart from that we are using the NGINX as our web server and Laravel as our framework. We also contacted the Google support team but couldn’t worked.

Front and Backend Load Balancer Configuration:

  • PHP Framework – Laravel V8
  • Compute Engine – Debian 10 Buster

Below is the code for NGINX config file.

NGINX Default Config file


server 
{
   listen 80;

    server_name example.in www.example.in;

    root /var/www/html/test;

    add_header X-Frame-Options "SAMEORIGIN";

    add_header X-XSS-Protection "1; mode=block";

    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {

        try_files $uri $uri/ /index.php?$query_string;

    }

    location = /favicon.ico { access_log off; log_not_found off; }

    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ .php$ {

        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

        include fastcgi_params;

    }

    location ~ /.(?!well-known).* {

        deny all;

    }

}

Front End Configuration

Backend Configuration

2

Answers


  1. Chosen as BEST ANSWER

    So the below configuration really solved my issue .

    I just added a new Port 80 (Http) configuration in my Front End configuration of my Load Balancer along with the Port 443 (Https) .

    Now the Domain URL is getting redirected from http to https with secure connections.

    Please refer to the below Screenshot of my Load Balancer Frontend Configuration .

    Load Balancer Frontend Configuration

    Thank you @JohnHanley for your answer ;)


  2. I think your NGINX configuration needs to adjust to listen on port 443 and you need to get the SSL certificate accordingly.
    Please refer : https://cloud.google.com/community/tutorials/https-load-balancing-nginx.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search