selfhelp-iptables icon indicating copy to clipboard operation
selfhelp-iptables copied to clipboard

两个问题:GET /log 错误;反代后怎样屏蔽 8080 端口?

Open xtremforce opened this issue 3 years ago • 1 comments

有两个问题: 1、CentOS8 上,GET /log 一直空白。终端提示:执行命令cat | grep netfilter出错;exit status 1。根据你文中的说明改了 iptables.log 的路径后一样错误。其他 api 如 GET /record 等功能正常。 我自己尝试执行 cat /var/log/iptables.log |grep netfilter 并无问题,能显示有记录。

2、开启 --reverse 参数后,目的是用 NGINX 反代并隐藏掉本身的 api 接口才对吧?但这时 8080 端口依然可以直接访问,理应开启 reverse 后只允许 127.0.0.1 或指定 IP 访问才对吧?

有什么更好的方法可以做到吗?

我现在是在软件启动后,删掉原本的 iptable 规则,再加上新的规则:

RuleLine=`iptables -L -n --line-number | grep 8080|awk '{ print $1}'`
echo "Delete Rule NO.${RuleLine}"
iptables -D SELF_WHITELIST ${RuleLine}

iptables -I SELF_WHITELIST -p tcp --dport 8080 -j DROP
iptables -I SELF_WHITELIST -s 127.0.0.1 -p tcp --dport 8080 -j ACCEPT

xtremforce avatar Dec 05 '22 08:12 xtremforce

https://github.com/haojie06/selfhelp-iptables/releases/tag/2.4.1 试试最新的这个版本,reverse 不再默认添加白名单了,然后新版使用上会有一点点变化,都写在readme里面了

haojie06 avatar Mar 28 '23 04:03 haojie06