[英]Spring Boot, Debian, Embedded Tomcat close external port
This is my Spring Boot application properties:这是我的 Spring Boot 应用程序属性:
server.port: 8081
On Debian 9 I run Spring Boot war with Embedded Tomcat in the following way:在 Debian 9 上,我通过以下方式使用嵌入式 Tomcat 运行 Spring Boot war:
java -Dfile.encoding=UTF-8 -jar api-0.0.1.war
Right after that, I can access the application by the following url:在那之后,我可以通过以下网址访问该应用程序:
http://localhost:8081/api/v1.0
I'd like to close external access to 8081 port and leave only access to this port from the internal system.我想关闭对 8081 端口的外部访问,而只允许从内部系统访问该端口。
I order to achieve this, I applied the following rule:为了实现这一点,我应用了以下规则:
/sbin/iptables -A INPUT -p tcp --destination-port 8081 -j DROP
/sbin/service iptables save
but right now I'm unable to access url http://localhost:8081/api/v1.0 from another application on the same machine.但现在我无法从同一台机器上的另一个应用程序访问 url http://localhost:8081/api/v1.0 。
What am I doing wrong and how to fix it?我做错了什么以及如何解决?
您需要允许 localhost 发布。
iptables -A INPUT -p tcp -s localhost --destination-port 8081 -j ACCEPT
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.