在Vagrant中访问Apache vhost时出现问题
我有一个在Ubuntu上运行的Apache服务器。在我的在Vagrant中访问Apache vhost时出现问题,apache,vagrant,virtualhost,Apache,Vagrant,Virtualhost,我有一个在Ubuntu上运行的Apache服务器。在我的可用站点目录中,我有两个文件: cats.com.conf <VirtualHost *:80> ServerName cats.com ServerAlias cats.test DocumentRoot /var/www/cats.com </VirtualHost> <VirtualHost *:80> ServerName dogs.com ServerA
可用站点
目录中,我有两个文件:
cats.com.conf
<VirtualHost *:80>
ServerName cats.com
ServerAlias cats.test
DocumentRoot /var/www/cats.com
</VirtualHost>
<VirtualHost *:80>
ServerName dogs.com
ServerAlias dogs.test
DocumentRoot /var/www/dogs.com
</VirtualHost>
在我的主机
文件中:
127.0.0.2 cats.test
127.0.0.2 dogs.test
但是当我在我的浏览器中访问cats.test时,它无法连接。假设你的站点在你的Ubuntu虚拟机上测试时响应正确,那么它就缺少URL中的端口 Ubuntu虚拟机上的https监听端口80。当您指定漫游端口转发时:
Host IP | Host Port | Guest IP | Guest Port
----------------------------------------------
127.0.0.2 | 8000 | 10.0.2.15 | 80
它让Vagrant监听端口8080,并将流量转发到Ubuntu虚拟机的端口80
因此,在主机系统上,您必须将浏览器指向http://cats.test:8080/
信息:当您使用
http://example.com/
,默认为端口80(http://)。对于https://example.com/
它默认为端口443。但是http流量可以在任何端口上处理。您在要访问的域后面指定了端口:port。当您在ubuntu机器内测试是否有响应时,您的站点是否会响应?如果是,则必须从服务器转到http://cats.test:8080/
因为您将服务器的8080端口转发到Ubuntu的80端口。这就是答案,谢谢!如果你想写出来,我会把它标对。很高兴它有帮助,答案是:)
Host IP | Host Port | Guest IP | Guest Port
----------------------------------------------
127.0.0.2 | 8000 | 10.0.2.15 | 80