gpt4 book ai didi

无法通过 http 访问 nginx CentOS 7

转载 作者:太空宇宙 更新时间:2023-11-03 17:23:18 24 4
gpt4 key购买 nike

在vps上配置了nginx,但是通过http访问公网ip或者域名默认的index.html是访问不到的

nginx 配置

server {
listen 80 default_server;
server_name domainname.com;
root /usr/share/nginx/html;
index index.html;

location / {
}
}

最佳答案

默认情况下centos 7防火墙是屏蔽端口80

需要编辑下一个文件

/etc/firewalld/zones/public.xml

添加80端口

<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="ssh"/>
<service name="dhcpv6-client"/>
<port protocol="tcp" port="80"/>
</zone>

重新加载防火墙

firewall-cmd --reload

关于无法通过 http 访问 nginx CentOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50898751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com