我正在寻找一些关于我正在工作的stunnelconfiguration的帮助。 基本上我想有一个DMZ机器接受端口80和110的入站连接,然后通过端口22上的防火墙将它们转发到一台机器,然后机器将本地stream量转发到端口80和110。 这甚至有可能吗?
基本上我会在我的DMZ上有这个:
[http] listen = localhost:80 connect = server:22 cert = cert.pem [pop3] listen = localhost:110 connect = server:22 cert = cert.pem
在我的服务器上,我会有:
[http] listen = localhost:22 connect = localhost:80 [pop3] listen = localhost:22 connect = localhost:110
这有意义吗? 端口22已经在我的防火墙上打开了,我不想再打开另外两个端口。
任何信息,将不胜感激…
谢谢!
当然,这是可能的,但它根本不涉及到stunnel 。
你可以在你的DMZ机器和你的内部主机之间build立一个SSH隧道。 就像是:
on_dmz_host# ssh -L 80:localhost:80 -L 110:localhost:110 internal_server
这告诉ssh将DMZ主机上的端口80转发到内部服务器上的端口80,对于端口110也是如此。连接全部通过端口22上的ssh连接传输,因此不需要打开任何其他端口。
你也可以使用点对点的VPN来完成同样的事情(比如OpenVPN就是这么做的),不过说实话,只要打开防火墙上的端口就简单多了。
你也许可以使用stlnel和sslh: http ://www.rutschle.net/tech/sslh.shtml
sslh是一个小程序,它分析协议并根据协议redirect包。
根据手册页:
可以识别 HTTP,SSL,SSH,OpenVPN,tinc,XMPP的探测,并且可以使用正则expression式来testing任何其他协议 。
/usr/share/doc/sslh/examples/example.cfg(debian)提供了一个configuration文件示例。
这可能看起来像这样(我没有testing它):
verbose: true; foreground: true; inetd: false; numeric: false; transparent: false; timeout: 2; user: "nobody"; pidfile: "/var/run/sslh.pid"; listen: ( { host: "localhost"; port: "SOME_PORT"; } ); protocols: ( { name: "http"; host: "localhost"; port: "80"; probe: "builtin"; }, { name: "pop3"; host: "localhost"; port: "110"; probe: [ INSERT_REGEXP_IDENTIFYING_POP3_PACKETS_HERE ]; } );
你的stunnel server.conf会变成:
... [sslh] listen = localhost:22 connect = localhost:PORT_SSLH_IS_LISTENING_ON
除非stunnel有某种方式来区分哪个stream量是哪个协议(我怀疑),这是行不通的。 您将不得不在防火墙上再打开一个端口。