【问题标题】:Spring Boot, Debian, Embedded Tomcat close external portSpring Boot、Debian、Embedded Tomcat 关闭外部端口
【发布时间】:2019-07-29 02:23:14
【问题描述】:

这是我的 Spring Boot 应用程序属性:

server.port: 8081

在 Debian 9 上,我通过以下方式使用嵌入式 Tomcat 运行 Spring Boot war:

java -Dfile.encoding=UTF-8 -jar api-0.0.1.war

之后,我可以通过以下网址访问应用程序:

http://localhost:8081/api/v1.0

我想关闭对 8081 端口的外部访问,只保留内部系统对该端口的访问。

为了实现这一点,我应用了以下规则:

/sbin/iptables -A INPUT -p tcp --destination-port 8081 -j DROP
/sbin/service iptables save

但现在我无法从同一台机器上的另一个应用程序访问 url http://localhost:8081/api/v1.0

我做错了什么以及如何解决?

【问题讨论】:

    标签: spring-boot tomcat debian port iptables


    【解决方案1】:

    您需要允许本地主机发布。

    iptables -A INPUT -p tcp -s localhost --destination-port 8081 -j ACCEPT

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-12
      • 2016-03-28
      • 2018-12-08
      • 2017-11-06
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 2017-06-28
      相关资源
      最近更新 更多