Intereting Posts

将Apache虚拟主机redirect到虚拟机

我有一个专用的服务器运行apache2,我想有几个虚拟机(针对不同的开发环境)。 我已经成功地使用virtualbox创build虚拟机。

我的服务器在networking上有一个静态的IP,我有一个域名。

我想通过Apache上的虚拟主机将我的子域redirect到虚拟机。 可能吗 ? 怎么样 ?

对不起,如果这样的问题已经存在,我不知道要search什么关键字。

谢谢。

首先在虚拟机中设置NAT,以便在客户虚拟机上公开要提供的服务。

然后在你的apacheconfiguration中添加反向代理configuration。

假设您的主机的端口7890转换为您的客户的端口80 (或您所暴露的服务的相关端口),您可以执行以下操作。

 <VirtualHost *:80> DocumentRoot /home/demo/public_html ServerName demo.example.com ErrorLog /var/log/apache2/demo-error.log CustomLog /var/log/apache2/demo.-access.log common ProxyRequests Off ProxyPass / http://127.0.0.1:7890 ProxyPassReverse / http://127.0.0.1:7890 </VirtualHost> 

您将需要启用proxyproxy_http apache模块(Ubuntu上的sudo a2enmod http http_proxy )。