nginx 在 fireswalld 下无法访问, 希望大佬指点 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
fov6363
V2EX    Linux

nginx 在 fireswalld 下无法访问, 希望大佬指点

  •  
  •   fov6363 2018-10-11 10:07:56 +08:00 2226 次点击
    这是一个创建于 2587 天前的主题,其中的信息可能已经有所发展或是发生改变。

    背景

    • 服务器: centos 7
    • iptables 已关闭
    • 阿里云端口已打开 80 端口, 关了 firewalld 即可外网访问可以证明这一点

    现象

    • firewalld 打开即无法访问 nginx, 关闭即可访问 nginx, nginx 在服务器上通过 curl 可以正确显示, 在外网访问即无效

    • systemctl start firewalld, 外网无法访问, systemctl stop firewalld, 外网即可访问.

    • 外网访问

     ~ curl -v http://39.107.204.247:80 * Rebuilt URL to: http://39.107.204.247:80/ * Trying 39.107.204.247... * TCP_NODELAY set * Connected to 39.107.204.247 (39.107.204.247) port 80 (#0) > GET / HTTP/1.1 > Host: 39.107.204.247 > User-Agent: curl/7.54.0 > Accept: */* > < HTTP/1.1 302 < Cache-Control: private < Expires: Thu, 01 Jan 1970 08:00:00 CST < Location: https://39.107.204.247/ < Content-Length: 0 < Date: Thu, 11 Oct 2018 01:54:33 GMT < * Connection #0 to host 39.107.204.247 left intact ~ 
    • 服务器本机访问
    [root@iZ2ze36uo36nxexxnfulpxZ ~]# curl -v http://39.107.204.247:80 * About to connect() to 39.107.204.247 port 80 (#0) * Trying 39.107.204.247... * Connected to 39.107.204.247 (39.107.204.247) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: 39.107.204.247 > Accept: */* > < HTTP/1.1 200 OK < Server: nginx/1.12.2 < Date: Thu, 11 Oct 2018 01:55:06 GMT < Content-Type: text/html < Content-Length: 3700 < Last-Modified: Tue, 06 Mar 2018 09:26:21 GMT < Connection: keep-alive < ETag: "5a9e5ebd-e74" < Accept-Ranges: bytes < <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> ....省略 html 内容 

    firewalld 配置

    • 备注: 已--reload 多次, 且多次尝试 start + stop
    [root@iZ2ze36uo36nxexxnfulpxZ ~]# firewall-cmd --list-all public target: default icmp-block-inversion: no interfaces: sources: services: ssh dhcpv6-client http https mysql ports: 80/tcp 443/tcp 3306/tcp 3611/tcp 9000/tcp protocols: masquerade: no forward-ports: port=80:proto=tcp:toport=8080:toaddr= port=443:proto=tcp:toport=8443:toaddr= source-ports: icmp-blocks: rich rules: 

    nginx

    [root@iZ2ze36uo36nxexxnfulpxZ ~]# ps -ef|grep nginx root 20510 1 0 10 月 10 ? 00:00:00 nginx: master process /usr/sbin/nginx nginx 20511 20510 0 10 月 10 ? 00:00:00 nginx: worker process nginx 20512 20510 0 10 月 10 ? 00:00:00 nginx: worker process root 23573 23536 0 10:00 pts/0 00:00:00 grep --color=auto nginx 
    • 想不出来啥原因, 请大佬指点

    • 备注: 此台服务器还有一个 java 程序, 关闭 firewalld 则无法访问该程序, 但把该 java 程序关闭掉, 现象也是和上面一样, 所以应该不是该 java 程序的原因

    2 条回复    2018-10-11 10:15:12 +08:00
    e9e499d78f
        1
    e9e499d78f  
       2018-10-11 10:09:52 +08:00 via iPhone   1
    里面有个 forward 80 到 8080 的规则
    fov6363
        2
    fov6363  
    OP
       2018-10-11 10:15:12 +08:00
    @e9e499d78f 感谢,这么一说我忽然明白了....我没看懂那个 forward-ports 是什么意思, 你这样一说,我忽略明白了...那个 java 程序是 8080 端口的..我尝试改一波
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1207 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 24ms UTC 23:38 PVG 07:38 LAX 15:38 JFK 18:38
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86