无法从 MAC 在 VirtualBox 上的 Centos7 上通过 HTTPS 连接到 Apache 服务器

Unable to connect to Apache server over HTTPS on Centos7 on VirtualBox from MAC

我在 VirtualBox 机器上配置了 Centos 7 OS。我已经使用 Openssl 工具安装了 X509 证书并配置了 apache HTTPD 服务器。

我在本地 MAC OSX Seirra (10.12.3) 终端上使用 root 通过 SSH 连接到 VirtualBox 上的 Centos7 客户机。
我已验证 MAC 上的 /etc/host 正确指向 VirtualBox 上的来宾。还验证了 VirtualBox 上的端口转发,它们都已正确设置以允许 80 (http) 和 443 (https) 以及 22 (ssh) 上的流量。此外,我还确保 Apache 用户在 index.html 上具有适当的权限和 DocumentRoot 文件夹下的其他文件夹。我还验证了 MAC 上的 /etc/host 正确指向 VirtualBox 上的访客 运行ning。

我已将防火墙设置为:

setenforce 0

希望这不是 SELinux 问题。

然后我 运行 作为 Centos7 的根用户在终端上执行以下命令 OS :

curl https://localhost -k

我确实得到了默认的 index.html 文件内容。

但是,当我转到 MAC OS 浏览器以通过 HTTPS 连接到 VirtualBOX 网站时,我在 Chrome 浏览器上看到以下消息:

This site can’t be reached
localhost refused to connect.


请注意,我可以通过 HTTP 连接到我的 Vbox CentOS HTTPD 服务器。
那么当尝试使用 HTTPS 访问 apache 服务器时出现了什么问题?

您必须使用 firewall-cmd 启用对 https 的访问:

# firewall-cmd --permanent --add-service=https

# firewall-cmd --permanent --add-port=443/tcp

然后重新加载规则

# firewall-cmd --reload

试试这个。

systemctl 停止 firewalld

之后尝试访问网站。