Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google HTTP load balancing enforce HTTPS

I have a HTTP and HTTPS load balancer on Goole Cloud. Is it possible to set it up to enforce (redirect) all connections to HTTPS?

like image 734
Upio Avatar asked Nov 10 '22 11:11

Upio


1 Answers

Not at the load balancer as of June 2015.

As an alternative, you can configure your web servers to return 301 for all HTTP requests redirecting to the HTTPS version.

For Apache (from https://wiki.apache.org/httpd/RedirectSSL):

NameVirtualHost *:80
<VirtualHost *:80>
   ServerName www.example.com
   Redirect permanent / https://www.example.com/
</VirtualHost>

<VirtualHost _default_:443>
   ServerName www.example.com
   DocumentRoot /my/document/root
   SSLEngine On
   # .. etc .
</VirtualHost>

For nginx (from https://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-http-requests-to-https-while-maintaining-sub-dom):

server {
    listen [::]:80;
    return 301 https://$host$request_uri; 
}
like image 135
Matt S. Avatar answered Nov 15 '22 07:11

Matt S.