我有一个用于托pipe多个站点的Linode VPS。 我运行Ubuntu 10.04和Apache 2.我想要做的是让我的活网站(example-site.com)和testing网站(test.example-site.com)在同一个盒子,但有test.example-站点。 com只有通过VPN连接到我的VPS时才可以访问。
我已经按照Linode的说明安装了OpenVPN,并且能够连接,但我不知道如何设置Apache来启用它。 如何设置Apache以允许连接到VPN时访问testing站点,但是允许任何人访问活动站点?
让Apache中的虚拟主机定义监听不同的接口。
说,OpenVPN的接口是10.8.0.101。 在这种情况下,在VirtualHost 10.8.0.101:80虚拟主机定义中,设置VirtualHost 10.8.0.101:80 。 同样,对于www.example.com,将其设置为在VirtualHost 192.168.1.1:80类的主接口上侦听,或者无论eth0接口的IP是什么。
我假设你在这里运行Linux / BSD,我相信你也可以用ssh来做同样的事情。
另一种方式只是使用SSH(我使用的是授权密钥而不是密码)
VARS取代您的select
$PORT = The port you wish to set this up on $YOURSITE = The directory your test site resides in $YOURTESTURL = The url of your test site $USER = the user you have setup to ssh into your server with $YOURSERVER = the ip or url of your server
服务器上的apacheconfiguration
<VirtualHost 127.0.0.1:$PORT> DocumentRoot /var/www/$YOURSITE/ ServerName $YOURTESTURL </VirtualHost>
现在在你的terminal投入
ssh -L $PORT:127.0.0.1:$PORT $USER@$YOURSERVER
现在打开你的浏览器到$ YOURTESTURL:$ PORT
我用它连接到我的服务器上的pipe理网站,而不必暴露他们的interwebs 🙂
希望这可以帮助