Spring Boot webapp localhost only

问题描述 投票:4回答:2

有没有办法让Spring Boot webapp关闭使用的端口?目前,我可以从localhost和本地网络中的其他计算机进行访问。目标是只能在本地访问webapp。

谢谢。

java spring-boot localhost
2个回答
10
投票

好的,除了设置防火墙之外,您还可以将服务器绑定到localhost。

这是通过放置来完成的

server.address=127.0.0.1

在资源中的application.properties文件里面


2
投票

添加到@Dani Cuesta的答案:

你添加:server.address=127.0.0.1

可以在以下资源中找到有关此值和其他允许值的说明:(对于“嵌入式服务器”特定参数,请参见“EMBEDDED SERVER CONFIGURATION(ServerProperties)”部分

allowed values in application.properties

© www.soinside.com 2019 - 2024. All rights reserved.