title: Apache 2.4 forward Proxy Configuration Issue
body: <p>I am trying to configure a Apache forward proxy with SSL. Below is my virtual host configuration. </p>
  
  <pre><code>Listen 192.168.2.1:12149
  &lt;VirtualHost 192.168.2.1:12149&gt;
    ServerName ech-192-168-2-1.test.com
    SSLEngine On
    SSLCertificateFile /opt/ssl/apache-selfsigned-new.crt
    SSLCertificateKeyFile /opt/ssl/apache-selfsigned-new.key
  
    ProxyVia On
    ProxyRequests On
    SSLProxyEngine On
    RewriteEngine On
  
    RewriteCond %{REQUEST_URI} !https://www.google.com/ [NC]
    RewriteCond %{REQUEST_URI} !http://www.google.com/ [NC]
    RewriteRule .* - [F]
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>Scenario 1:</strong> Using Curl try to access <a href="https://www.goole.com" rel="nofollow noreferrer">https://www.goole.com</a></p>
  
  <pre><code>curl  -v --proxy 192.168.2.1:12149 https://www.google.com
  * About to connect() to proxy 192.168.2.1 port 12149 (#0)
  *   Trying 192.168.2.1... connected
  * Connected to 192.168.2.1 (192.168.2.1) port 12149 (#0)
  * Establish HTTP proxy tunnel to www.google.com:443
  &gt; CONNECT www.google.com:443 HTTP/1.1
  &gt; Host: www.google.com:443
  &gt; User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
  &gt; Proxy-Connection: Keep-Alive
  &gt;
  * Proxy CONNECT aborted
  * Closing connection #0
  curl: (56) Proxy CONNECT aborted
  </code></pre>
  
  <p><strong>Seenario 2:</strong> Using Curl try to access <a href="http://www.google.com" rel="nofollow noreferrer">http://www.google.com</a></p>
  
  <pre><code>curl  -v --proxy 192.168.2.1:12149 http://www.google.com
  * About to connect() to proxy 192.168.2.1 port 12149 (#0)
  *   Trying 192.168.2.1... connected
  * Connected to 192.168.2.1 (192.168.2.1) port 12149 (#0)
  &gt; GET http://www.google.com/ HTTP/1.1
  &gt; User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
  &gt; Host: www.google.com
  &gt; Accept: */*
  &gt; Proxy-Connection: Keep-Alive
  &gt;
  &lt; HTTP/1.1 400 Bad Request
  &lt; Date: Wed, 15 Feb 2017 10:03:52 GMT
  &lt; Server: Apache
  &lt; Content-Length: 362
  &lt; Connection: close
  &lt; Content-Type: text/html; charset=iso-8859-1
  &lt;
  &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  &lt;html&gt;&lt;head&gt;
  &lt;title&gt;400 Bad Request&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;h1&gt;Bad Request&lt;/h1&gt;
  &lt;p&gt;Your browser sent a request that this server could not understand.&lt;br /&gt;
  Reason: You're speaking plain HTTP to an SSL-enabled server port.&lt;br /&gt;
   Instead use the HTTPS scheme to access this URL, please.&lt;br /&gt;
  &lt;/p&gt;
  &lt;/body&gt;&lt;/html&gt;
  * Closing connection #0
  </code></pre>
  
  <p>But when I am disabling SSL in the virtual host and trying to connect outbound http it's working. </p>
  
  <p>Virtual host Configuration:</p>
  
  <pre><code>Listen 192.168.2.1:12149
  &lt;VirtualHost 192.168.2.1:12149&gt;
    ServerName ech-192-168-2-1.test.com
    #SSLEngine On
    #SSLCertificateFile /opt/ssl/apache-selfsigned-new.crt
    #SSLCertificateKeyFile /opt/ssl/apache-selfsigned-new.key
  
    ProxyVia On
    ProxyRequests On
    #SSLProxyEngine On
    RewriteEngine On
  
    RewriteCond %{REQUEST_URI} !https://www.google.com/ [NC]
    RewriteCond %{REQUEST_URI} !http://www.google.com/ [NC]
    RewriteRule .* - [F]
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>Scenario 1:</strong> Using Curl try to access <a href="https://www.goole.com" rel="nofollow noreferrer">https://www.goole.com</a></p>
  
  <pre><code>curl  -v --proxy 192.168.2.1:12149 https://www.google.com
  * About to connect() to proxy 192.168.2.1 port 12149 (#0)
  *   Trying 192.168.2.1... connected
  * Connected to 192.168.2.1 (192.168.2.1) port 12149 (#0)
  * Establish HTTP proxy tunnel to www.google.com:443
  &gt; CONNECT www.google.com:443 HTTP/1.1
  &gt; Host: www.google.com:443
  &gt; User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
  &gt; Proxy-Connection: Keep-Alive
  &gt;
  &lt; HTTP/1.1 500 Internal Server Error
  &lt; Date: Wed, 15 Feb 2017 10:13:15 GMT
  &lt; Server: Apache
  &lt; Content-Length: 546
  &lt; Connection: close
  &lt; Content-Type: text/html; charset=iso-8859-1
  &lt;
  * Received HTTP code 500 from proxy after CONNECT
  * Closing connection #0
  curl: (56) Received HTTP code 500 from proxy after CONNECT
  </code></pre>
  
  <p><strong>Seenario 2:</strong> Using Curl try to access <a href="http://www.google.com" rel="nofollow noreferrer">http://www.google.com</a></p>
  
  <pre><code>curl  -v --proxy 192.168.2.1:12149 http://www.google.com
  * About to connect() to proxy 192.168.2.1 port 12149 (#0)
  *   Trying 192.168.2.1... connected
  * Connected to 192.168.2.1 (192.168.2.1) port 12149 (#0)
  &gt; GET http://www.google.com/ HTTP/1.1
  &gt; User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
  &gt; Host: www.google.com
  &gt; Accept: */*
  &gt; Proxy-Connection: Keep-Alive
  &gt;
  &lt; HTTP/1.1 302 Found
  &lt; Date: Wed, 15 Feb 2017 10:14:20 GMT
  &lt; Server: Apache
  &lt; Location: http://www.cfauth.com/?cfru=aHR0cDovL3d3dy5nb29nbGUuY29tLw==
  &lt; Cache-Control: no-cache
  &lt; Pragma: no-cache
  &lt; Content-Type: text/html; charset=utf-8
  &lt; Content-Length: 660
  &lt; Via: 1.1 ech-192-168-2-1.test.com
  &lt;
  &lt;HTML&gt;&lt;HEAD&gt;
  &lt;TITLE&gt;Redirect&lt;/TITLE&gt;
  &lt;/HEAD&gt;
  &lt;BODY&gt;
  &lt;FONT face="Helvetica"&gt;
  &lt;big&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/big&gt;&lt;BR&gt;
  &lt;/FONT&gt;
  &lt;blockquote&gt;
  &lt;TABLE border=0 cellPadding=1 width="80%"&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica"&gt;
  &lt;big&gt;Redirect (authentication_redirect_to_virtual_host)&lt;/big&gt;
  &lt;BR&gt;
  &lt;BR&gt;
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica"&gt;
  You are being redirected to the authentication virtual host.
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica"&gt;
  
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica" SIZE=2&gt;
  &lt;BR&gt;
  For assistance, contact your network support team.
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;/TABLE&gt;
  &lt;/blockquote&gt;
  &lt;/FONT&gt;
  &lt;/BODY&gt;&lt;/HTML&gt;
  * Connection #0 to host 192.168.2.1 left intact
  * Closing connection #0
  </code></pre>