【发布时间】:2021-01-15 14:32:59
【问题描述】:
我有两台使用 centos 7 的服务器虚拟机。使用 IP 公共103.x.x.78 和域one.example.go.id
此 IP 本地为 192.168.10.200(服务器 A)。
我创建了另一个具有本地 IP 的 VM 192.168.10.103(服务器 B)。计划指向我的另一个域two.example.go.id
这是我的配置:
one.example.go.id pointing to 103.x.x.78
我已经使用 DocumentRoot /var/www/html 创建了 VirtualHost 并开始工作。
然后
two.example.go.id pointing to 103.x.x.78
我尝试打开这个域工作。打开网页。
在服务器 A 上创建 /etc/hosts:
192.168.10.103 two.example.go.id
并在服务器 B 上创建 VirtualHost
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.two.example.go.id
ServerAlias two.example.go.id
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:443>
ServerName www.two.example.go.id
ServerAlias two.example.go.id
DocumentRoot /var/www/html
</VirtualHost>
我可以在服务器 A 中访问 IP 192.168.10.103 或 two.example.go.id,它可以完美加载。但是当我在其他设备(互联网)中使用 two.example.go.id 访问时,它不起作用。无法访问此站点。
我错过了一步吗?
*这是我英语不好的第一个问题。 CMIIW
【问题讨论】:
-
您是否还向服务器 B 添加了
/etc/hosts?因为/etc/hosts仅适用于您添加它的设备。例如,如果您在服务器 A 中添加/etc/hosts指令,它只适用于服务器 A。您也必须为服务器 B 添加相同的指令。
标签: apache centos7 virtualhost firewall hosts