简体   繁体   English

配置Spring Boot以侦听本地主机旁边的请求

[英]Configure Spring Boot to listen for request beside localhost

I am connected to dormitory subweb. 我已连接到宿舍子网站。 I have 2 machines with external ip adresses. 我有2台带有外部IP地址的机器。 ( I am able to ping them or connect with them via SSH) Raspberry Pi running ubuntu mate where my Spring Boot server is hosted and other machine running Windows 10. Problem is that Spring server do not respond to requests from any source beside dormitory web (DW). (我可以对其进行ping操作或通过SSH与之连接)Raspberry Pi运行ubuntu mate并在其中托管我的Spring Boot服务器,而其他计算机则运行Windows10。问题是Spring服务器无法响应来自宿舍网络( DW)。 I found that Issue is 8080 port closed. 我发现问题是8080端口关闭。 when I scan for open ports from beside DW I can only see 22 port opened, Computers inside DW see 8080 and 22 ports as opened and are able to respond HTTP server. 当我从DW旁边扫描打开的端口时,我只能看到22个端口已打开,DW内部的计算机看到8080和22个端口为打开状态,并且能够响应HTTP服务器。

From what I have read here I have to set server.address property to be accessible from "outside" 从我在这里阅读的内容中我必须将server.address属性设置为可从“外部”访问

My spring application.properties 我的春季application.properties

#mysql test config
spring.datasource.url=jdbc:mysql://localhost:3306/springboot
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver`
spring.jpa.show-sql=true

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy

#initialization
spring.datasource.schema=classpath:/data/schema.sql

#server
server.address= my.adres.here
server.port = 8080

I am sure that sever reads this file properly. 我确信服务器会正​​确读取此文件。

I also tried turn off firewall temporarily 我也尝试过暂时关闭防火墙

sudo ufw disable

to check if it blocks connection on this port but thats not the issue. 检查它是否阻止了该端口上的连接,但这不是问题。

I am not sure where the real problem may be localized. 我不确定真正的问题可能在哪里定位。 Could it be something wrong with Spring Boot config? Spring Boot config可能有问题吗? Or maybe it is some networking issue. 也许这是一些网络问题。

由于@Robert Masen提出的问题是宿舍网络阻塞了8080端口上的连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM