Skip to content

Instantly share code, notes, and snippets.

@vovanmix
Last active July 11, 2016 18:30
Show Gist options
  • Select an option

  • Save vovanmix/054021d00f55b075e5bc8a6c2ddb34ac to your computer and use it in GitHub Desktop.

Select an option

Save vovanmix/054021d00f55b075e5bc8a6c2ddb34ac to your computer and use it in GitHub Desktop.
http -> https redirect on AWS using load balancer

We create a separate port listener in web server config, forwart all HTTP connections from load balancer to this port, and configure web server to redirect all connections on this port to https

#add port 1443 listener to EC2 security group

Custom TCP Rule   TCP   1443  <load balancer group id>

#add load balancer rules:

HTTP	  80	  HTTP	  1443	  N/A	        N/A
HTTPS	  443	  HTTP	  80	    <Cipher>	  <SSL Certificate>

#add web server config apache:

Listen 1443

<VirtualHost *:1443>
    RewriteEngine On
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
</VirtualHost>

nginx:

server {
    listen     1443;
    return     301 https://$server_name$request_uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment