Apache Proxy Https To Http



Apache is the most popular open source web server. Apache can be configured as a proxy to redirect HTTP traffic to other servers. When Apache is configured as a reverse proxy, it receives HTTP requests from the user, and forwards them to backend server to process the request and sends a response through the proxy back to the client.

Install Apache

Redirect HTTP to HTTPS on Apache Virtual Host Additionally, to force all web traffic to use HTTPS, you can also configure your virtual host file. Normally, there are two important sections of a virtual host configurations if an SSL certificate is enabled; the first contains configurations for the non-secure port 80. Whereas HTTPS is the secure version of HTTP, where the ‘S‘ at the end stands for ‘Secure‘. Using HTTPS, all data between your browser and the web server are encrypted thus secure. This tutorial will show you how to redirect HTTP to HTTPS on Apache HTTP server in Linux.

Once Apache has been installed, start the Apache service

Install dependencies for mod_proxy

mod_proxy is the Apache module that implements a proxy for Apache HTTP Server. Below command to install dependencies.

Run the following command to install build-essential package:

Activate mod_proxy module

Modify The Default Configuration

Copy-and-paste the below block of configuration

Save the file and restart apache.

When you access the URL http://server-ip-address:80 in a browser, it will show the application which is running on http://server-ip-address:8080. The browser is not aware that the application is running on port 8080.

Enable SSL Reverse-Proxy Support

Restart the Apache service for the change to be recognized.

Generate Self-Signed SSL Certificate

We need to generate a private key (ca.key) with 2048 bit encryption.

Then generate a certificate signing request (ca.csr)

Above command Prompt info.

Lastly, generate a self-signed certificate (ca.crt) of X509 type valid for 365 keys.

Https

Create a directory to place the certificate files we have created.

Next, copy all certificate files to the /etc/apache2/ssl directory.

Here, we need to create new virtual host file proxy-ssl-host.conf

Add the following content:

Apache Proxypass Https

Enable new virtual host file:

Reverse Proxy

Now, restart the Apache service

Apache 2.4 Reverse Proxy Https To Http

That’s it. You can now access your server using the URL https://server-ip-address. and Apache will reverse-proxy connections to your back-end application servers.

Apache Reverse Proxy Https To Http

Happy Reading…