OpenVPN端口与Apache / SSL共享

我试图设置OpenVPN来侦听端口443,然后通过使用port-share选项将所有HTTPS通信传递给Apache。 相关的configuration片段是:

OpenVPN的

 local ${PUBLIC_IP} port 443 port-share localhost 443 

Apache与SSL

 Listen localhost:443 

我的OpenVPN客户端连接正常,但是当打开启用HTTPS的页面时,出现错误。 Firefox说:

SSL收到的logging超出了允许的最大长度。

(错误代码:ssl_error_rx_record_too_long)

卷毛说

curl:(35)错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议

请求最终在Apache上,因为我在错误日志中看到以下消息:

 [Wed Oct 06 01:10:20 2010] [error] [client 127.0.0.1] Invalid method in request \x16\x03\x01 [Wed Oct 06 01:11:04 2010] [error] [client 127.0.0.1] Invalid method in request \x16\x03\x01 [Wed Oct 06 01:11:51 2010] [error] [client 127.0.0.1] Invalid method in request \x16\x03\x01 

HTTPS连接的消息条目是

 Oct 6 01:13:21 ns1 openvpn[20154]: Re-using SSL/TLS context Oct 6 01:13:21 ns1 openvpn[20154]: LZO compression initialized Oct 6 01:13:21 ns1 openvpn[20154]: Control Channel MTU parms [ L:1544 D:140 EF:40 EB:0 ET:0 EL:0 ] Oct 6 01:13:21 ns1 openvpn[20154]: Data Channel MTU parms [ L:1544 D:1450 EF:44 EB:135 ET:0 EL:0 AF:3/1 ] Oct 6 01:13:21 ns1 openvpn[20154]: Local Options hash (VER=V4): 'c0103fa8' Oct 6 01:13:21 ns1 openvpn[20154]: Expected Remote Options hash (VER=V4): '69109d17' Oct 6 01:13:21 ns1 openvpn[20154]: TCP connection established with ${CLIENT_IP}:56203 Oct 6 01:13:21 ns1 openvpn[20154]: TCPv4_SERVER link local: [undef] Oct 6 01:13:21 ns1 openvpn[20154]: TCPv4_SERVER link remote: ${CLIENT_IP}:56203 Oct 6 01:13:21 ns1 openvpn[20154]: ${CLIENT_IP}:56203 Non-OpenVPN client protocol detected Oct 6 01:13:21 ns1 openvpn[20154]: TCP/UDP: Closing socket 

使用httpd-2.2.3-43.el5.centos和openvpn-2.1.1-2.el5。

我应该做些什么来使端口共享工作?


更新 :使用

 port 443 port-share localhost 10443 

 Listen localhost:10443 

没有区别。


更新2 :一些命令输出

 [root@ns1 ~]# openvpn --help | grep port-share --port-share host port : When run in TCP mode, proxy incoming HTTPS sessions [root@ns1 ~]# netstat -nltp | grep 443 tcp 0 0 127.0.0.1:10443 0.0.0.0:* LISTEN 20088/httpd tcp 0 0 ${PUBLIC_IP}:443 0.0.0.0:* LISTEN 20066/openvpn 

port-share选项设置其他应用程序正在侦听的端口。

你想要做的是configuration

端口共享10443

并将Apache设置为在端口10443上进行侦听:

听<your-public-ip>:10443

这是因为两个应用程序无法一次打开相同的端口。

OpenVPN的端口共享选项允许您将stream量redirect到另一个HTTPS站点,而不是常规Web服务器; 你看到的错误

 [error] [client 127.0.0.1] Invalid method in request \x16\x03\x01 

在SSL请求发送到非0SSL站点时发生。 我可以通过使用重现错误

  port-share localhost 80 

(而不是443)如果您正确设置了HTTPS站点,则端口共享将起作用。

HTH,

JJK

正如在我find一个适合我的服务器的答案的过程中,我发现每个人都在谈论OpenVPNconfiguration的portsharefunction。 但是,在我的情况下,当需要知道客户端的IP地址以进行日志logging和其他function时,我发现使用portshare会导致服务器的本地IP被logging。

为了解决这个问题,我发现打开OpenVPN中的portsharefunction,并设置Apache服务器监听这个端口,就可以安装ProxyProtocol扩展。 该页面提供了扩展名: https : //github.com/roadrunner2/mod-proxy-protocol ,安装起来并不困难。 按照自述文件中的说明安装此扩展。 然后,在Apacheconfiguration中添加ProxyProtocol On行。 它应该工作和服务于上述目的。 只是张贴这个,并希望它可以帮助一个人想要做一些像我这样的事情。