Apache Http To Https

I'm using HTTP and HTTPS listeners on my Classic Load Balancer. My Classic Load Balancer offloads SSL, and the backend connection listens on a single HTTP port (port 80). When I try to redirect traffic from HTTP to HTTPS (port 443), I receive the error 'ERR_TOO_MANY_REDIRECTS'. How do I resolve this error without changing my backend listener to port 443?

  1. Apache Http To Https Rewrite
  2. Apache Https Rewrite
  3. Apache Http To Https Redirect Permanent
  4. Https Apache Server

Short description

  • Redirect HTTP to HTTPS is a very good thing and i cannot see any drawbacks for that. Just make sure your clients have the right CA to avoid non user-friendly warnings about certificate in browser. In addition, the way you have setup Apache to redirect to HTTPS seems ok.
  • That's all there is to the setup of https on Apache with CentOS. You can do a quick test by pointing a browser to You should receive a security warning (since we are using a.
  • Apache is a tried and tested HTTP server which comes with access to a very wide range of powerful extensions. Although it might not seem like the go-to choice in terms of running a reverse-proxy, system administrators who already depend on Apache for the available rich feature-set can also use it as a gateway to their application servers.
  • To configure Apache for HTTPS, the modssl module is used. When the httpd module was installed, the modssl module was also installed. If it wasn't installed, use yum to add it to the configuration. Sudo yum install modssl To enforce HTTPS, install the modrewrite module to enable URL rewriting: sudo yum install modrewrite.

Classic Load Balancers can't redirect HTTP traffic to HTTPS. Instead, you can include rewrite rules on the web servers of Amazon Elastic Compute Cloud (Amazon EC2) instances behind your Classic Load Balancer.

19 hours ago  Apache Redirection from HTTPS to HTTP and HTTPS? Apache httpd reverse proxy returns SSLERRORRXRECORDTOOLONG when HTTP redirects to HTTPS. Redirect on the same port from http to https with nginx reverse proxy. Apache 2.4 with self-signed certificates always redirect to the default virtual host.

You must configure your rewrite rules to use the X-Forwarded-Proto header and redirect only HTTP clients. Otherwise, the rewrite rules can create an infinite loop of redirection requests between your Classic Load Balancer and the instances behind it. Such a loop results in the error 'ERR_TOO_MANY_REDIRECTS'.

Note: Application Load Balancers can redirect HTTP traffic to HTTPS using redirect actions. Migrate your Classic Load Balancer to an Application Load Balancer to use this feature.


Review the following example configurations for Apache, NGINX, and IIS web servers. Configure the web servers behind your Classic Load Balancer to use the X-Forwarded-Proto header to direct traffic based on whether clients use HTTP or HTTPS. Be sure to add rewrite rules to your web servers that:

  • Redirect clients using HTTP to an HTTPS URL
  • Serve clients using HTTPS directly

Important: The following configurations are provided as examples only. Modify them based on your configuration and use case.

Apache servers: Virtual host file method (best practice)

1. Open your Apache configuration file. Possible locations include /etc/httpd/conf/httpd.conf (Apache 2/httpd), /etc/apache2/sites-enabled/ (Apache 2.4), or /etc/apache2/apache2.conf (Apache on Ubuntu).

2. Add a rewrite rule to the VirtualHost section of your configuration file similar to the following:

3. Save your Apache configuration file.

4. Restart Apache.

Apache servers: .htaccess file method (not a best practice)

Warning: It's a best practice to use the Apache virtual host file method described in the previous section. According to the Apache .htaccess files guidelines, use .htaccess files only if you don't have access to the main Apache configuration file.

1. Open your Apache configuration file. Possible locations include /etc/httpd/conf/httpd.conf (Apache 2/httpd) or /etc/apache2/sites-enabled/ (Apache 2.4).

2. Edit the Directory directive to enable .htaccess as follows:

3. Save your Apache configuration file.

4. Open your .htaccess file.

5. Add a rewrite rule similar to the following:

6. Save your .htaccess file.

7. Restart Apache.

NGINX servers

Note: This resolution applies to NGINX 1.10.3 (Ubuntu) and NGINX 1.12.1 (Amazon Linux).

1. Open your NGINX configuration file (nginx.conf).

2. Add the following rewrite rule. Be sure to modify the rewrite rule for your configuration.

3. Restart NGINX.

IIS servers

Note: This resolution applies to Microsoft Windows Server 2012 R2 and 2016 Base.

Apache Http To Https Rewrite

1. Install the IIS URL rewrite module from Microsoft.

2. Open your web.config file.

3. Add the following rewrite rule to the <system.Webserver> section. Be sure to modify the rewrite rule for your specific configuration.

4. Save your web.config file. What is better than evernote.

5. Open the IIS Manager.

6. Refresh the default website.

Apache Https Rewrite

7. Verify that your new rewrite rule appears in the URL Rewrite section.

8. Restart your website.

9. Verify that your redirection works.

Related information

Apache Http To Https Redirect Permanent

Https apache server

Related videos

Hari shows you how to redirect HTTP traffic to HTTPS using a load balancer and Apache (8:38)

Https Apache Server

Apache Http To Https