Is it possible to have a forward proxy with ssl en

2019-07-18 11:23发布

问题:

First of all I want to make clear that i am not talking about accessing content which is on origin servers that deliver using https which can be done using the module mod_proxy_connect.

What I want is a secured connection between the client and the proxy, also when the origin that is requested actually is served by an unsecured standard http server.

I am using apache 2.2 and also would like to make this possible with apache if that works.

I sniffed some requests using wireshark and noted the following:

A usual http of the url http://example.com/file looksl ike this:

on a connection to the origin server:

GET /file HTTP 1.1
Host: example.com

Note that the host information is stripped from the actual request and the host header is supplied instead (which can be handled server side in named virtual hosts).

When the request goes through a proxy server it looks slightly different:

on a connection to the proxy server:

GET http://example.com/file HTTP 1.1
Host: example.com

Note that the request line now actually contains the full url including protocol and hostname. The host header is probably redundant, bus if I read the RFC correctly it is required by HTTP 1.1.

So I think about setting up an apache webserver listening on port 443, enable a virtualhost with ssl engine and certificates up and do not bind it to any hostname.

I think that should get apache to talk ssl, but however the certificates common name will not match the host specfied in the connect line to the proxys server ip adress.

Is what I want to to even possible with current standards and if so how can I do it?

回答1:

Yes of course, that's what HTTPS proxy is.

Client connects to proxy over SSL, sends commands to proxy in text.

It is also possible to use HTTP CONNECT to establish HTTPS connection "inside" the SSL connection to HTTPS proxy, though not all clients support this:

HTTPS connection over HTTPS proxy
client           proxy           server
ssl    \-------/   ssl
connect---------200 OK
ssl  \---------------------------/ ssl
data-------------------------------data
     /---------------------------\
       /-------\



HTTP connection over HTTPS proxy
client           proxy           server
ssl    \-------/   ssl
GET http://server/ ->
                       GET / 
                       Host: server ->
                       <---------OK, data
<--------------OK, data
       /-------\