apache - 在另一台服务器中使用 DocumentRoot 创建 VirtualHost
问题描述
我有两台使用 centos 7 的服务器虚拟机。使用 IP 公用103.x.x.78
和域one.example.go.id
此 IP 本地是192.168.10.200
(服务器 A)。
我创建了另一个具有 IP 本地192.168.10.103
(服务器 B)的 VM。计划指向我的另一个域two.example.go.id
这是我的配置:
one.example.go.id pointing to 103.x.x.78
我已经使用 DocumentRoot 创建了 VirtualHost/var/www/html
并开始工作。
然后
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
解决方案
/etc/hosts
您是否还向服务器 B添加了一个?因为/etc/hosts
仅适用于您添加它的设备。例如,如果您/etc/hosts
在服务器 A 中添加指令,则它仅适用于服务器 A。您也必须为服务器 B 添加相同的指令。
或者,如果您因此不想使用 /etc/hosts,那么您可以在本地网络中设置自己的 DNS 服务器。
推荐阅读
- elasticsearch - fscrawler 中的触摸命令
- ios - 复制 SKAudioNode 对象的问题
- git - 如何 git reset --hard
并删除所有本地不相关的标签? - firebase - 如何为所有用户仅使用一个帐户设置 Firebase 实时数据库身份验证
- docker - 如何在 docker 容器中正确安装 npm 包
- google-apps-script - 谷歌应用脚本无法通过工作表访问
- node.js - 使用 Google Cloud Functions 创建工作表
- ios - 如何指定具有 Text 、 Image 和 Carousel 3 种类型的聊天,并且我们的发送文本也显示在聊天中
- google-sheets - 如何在Google表格中将数字范围分组为数字范围类别
- r - 如何将时间序列输出导出到 R 数据库中的表中。(R Studio)