如果项目同时使用了nginx反向代理服务器和tomcat等web服务器,并且两台服务器都暴露于公网中,那么通常我们会禁止外网直接访问tomcat,因为以下原因:

1.如果可以直接访问tomcat,那么则绕过了nginx,nginx的静态服务等都将失效。

2.如果tomcat的8080端口可以正常访问网站,会导致搜索引擎收录类似http://www.xxx.com:8080之类的网页,不利于seo优化。

因此需要直接禁止用户通过http://www.xxx.com:8080这种方式访问网站,在Linux上可以采用防火墙来实现

 

#启动iptables服务
service iptables start
#设置iptables服务开机启动
chkconfig iptables on
#添加过滤规则
iptables -t filter -A INPUT -p tcp -m tcp --dport 8080 -s localhost -j ACCEPT
iptables -t filter -A INPUT -p tcp -m tcp --dport 8080 -j REJECT

iptables -t filter -A INPUT -p tcp -m tcp --dport 8080 -s 182.92.130.178 -j ACCEPT
iptables -t filter -A INPUT -p tcp -m tcp --dport 8080 -j REJECT

相关文章:

  • 2021-07-14
  • 2022-12-23
  • 2021-07-20
  • 2021-09-15
  • 2022-01-09
  • 2021-08-24
  • 2021-07-07
猜你喜欢
  • 2022-03-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-10-30
相关资源
相似解决方案