与 Apache/SSL 的 OpenVPN 端口共享

Rob*_*anu 9 ssl openvpn apache-2.2

我正在尝试设置 OpenVPN 以侦听端口 443,然后使用该port-share选项将所有 HTTPS 流量传递给 Apache 。相关的配置片段是:

开放式VPN

local ${PUBLIC_IP}
port 443
port-share localhost 443
Run Code Online (Sandbox Code Playgroud)

带有 SSL 的 Apache

Listen localhost:443
Run Code Online (Sandbox Code Playgroud)

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

SSL 收到超过最大允许长度的记录。

(错误代码: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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

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

我应该怎么做才能使端口共享工作?


更新:使用

port 443
port-share localhost 10443
Run Code Online (Sandbox Code Playgroud)

Listen localhost:10443
Run Code Online (Sandbox Code Playgroud)

没什么区别。


更新 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       
Run Code Online (Sandbox Code Playgroud)

Hub*_*rio 9

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

你想要做的是配置

端口共享 10443

并将 Apache 设置为侦听端口 10443:

听 <your-public-ip>:10443

那是因为两个应用程序不能同时打开同一个端口。