简体   繁体   English

Spring Boot、Debian、嵌入式 Tomcat 关闭外部端口

[英]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.

相关问题 Spring 引导微服务嵌入式 tomcat 与外部 tomcat - Spring Boot microservices Embedded tomcat vs External tomcat 具有嵌入式tomcat的Spring Boot在端口上运行,但无法正常工作 - Spring boot with embedded tomcat runs on a port but its won't work 嵌入式 Tomcat 10 不在 Spring 引导应用程序中的端口上侦听 - Embedded Tomcat 10 does not listen on port in Spring Boot application Spring 引导嵌入式 tomcat 中是否有用于 https 重定向的特定端口? - Is there any specific port for https redirection in Spring Boot embedded tomcat? 如何使用Spring Boot应用程序更改嵌入式tomcat连接器端口 - How to change embedded tomcat connector port using spring boot application 如何将外部xml文件推送到Spring Boot嵌入式tomcat Continer中 - How to push external xml file into spring boot embedded tomcat continer 如何在Spring Boot Embedded tomcat中维护外部静态HTML文件? - How to service external static HTML files in Spring Boot Embedded tomcat? spring boot的嵌入式tomcat服务器如何加载外部“war”文件 - How load a external "war" file to the embedded tomcat server of spring boot 部署到外部 Tomcat 容器时的 Spring Boot Actuator 端口 - Spring Boot Actuator port when deployed to external Tomcat container 在具有相同端口的外部 tomcat 上部署不同的 Spring Boot War - deploy different spring boot wars on external tomcat with same port
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM