Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

302 SSL Redirect – Apache Reverse Proxy.

Leer en espanol
302 SSL Redirect – Apache Reverse Proxy.

Table of contents

Inside the application ===

Sometimes we can find a site with SSL in which we have a reverse proxy that acts as an SSL terminator. Behind that reverse proxy, you have a web server.

Within the application it uses a 302 redirect to announce new URLs. Since the web server does not know that URLs have to be advertised using https, the response header is incorrect.

To solve this problem we have to configure the following line:

text
Header edit Location «^http:(.*)$» «https:$1»

Below is an example which performs a reverse proxy to a tomcat server and the application uses 302 redirects to announce the new URLs:

Apache
<VirtualHost _default_:443>
ServerAdmin rokitoh@red.orbita.com

DocumentRoot «/var/www/html/»

ServerName red.orbita.com

ServerAlias red.orbita.com

ErrorLog «/var/log/httpd/red.orbita.com-ssl-error_log»

CustomLog «/var/log/httpd/red.orbita.com-ssl-access_log» combined
ProxyRequests Off

ProxyPreserveHost On
<Proxy *>

Order deny,allow

Allow from all

</Proxy>
Header edit Location «^http:(.*)$» «https:$1»
ProxyPass / http://localhost:8080/

ProxyPassReverse / http://localhost:8080/
SSLProtocol ALL -SSLv2 -SSLv3

SSLHonorCipherOrder On

SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
SSLEngine on

SSLProxyEngine on
SSLCertificateFile /etc/httpd/certs/red.orbita.com.pem

SSLCertificateKeyFile /etc/httpd/certs/red.orbita.com.key
</VirtualHost>

:wq!

Comments