非常短的问题,
[vagrant@localhost ~]$ curl http://0.0.0.0
我可以看到 NGINX 和 Redhat 的整个 HTML 页面,但我无法使用 VirtualBox 的主机和访客网络的公共 IP 或桥接 IP (10.XX.XX....) 连接到该主机服务器。他们无限期地挂断了(是的,没有连接错误,只是无限加载)
[vagrant@localhost ~]$ sudo firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3
sources:
services: cockpit dhcpv6-client http ssh
ports: 80/tcp 443/tcp
protocols:
forward: yes
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
来自 nginx.conf:
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
问题与 VirtualBox + Vagrant 有关,因此添加了各自的标签。我只需在 Vagrantfile 中添加/取消注释这一行
config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
然后,瞧。我现在可以从
127.0.0.1:8080
访问 nginx 服务器。
因此,首先要执行以下步骤:
example.com
),或设置为任何内容 _
,而不是特定 ip(如 192.XXX
)。firewalld
中暴露,如果使用 CentOS,请对基于 Debian 的发行版进行研究。应该是一样的。