As far as I can see, in the documentation (1), one cannot let Spring Boot sniff out the IP address of the computer on its own. I would like to have this feature in application(-xxxx).properties. It would look, maybe, like this:
server.address={this.server}
Where "this.server" is some sort of Spring Boot magic that sorts out, by itself, what the IP address is on the computer where the application starts.
1) https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#common-application-properties-server
Comment From: wilkinsona
Thanks for the suggestion, but I don't think it would be possible for us to determine the IP address to use as it's quite common for a host to have more than one. For example, on my macOS laptop iterating all network interfaces and all their inet addresses, there are 10 different addresses.
Comment From: Adriansun
Thank you wilkinsona for the reply. May I add; Would it not be possible to somehow separate the real IP vs INET address vs other things vs router addresses etc...? All types can have their own magic in the properties file, for example INET interface no. 3:
server.address={this.inet.3.server.auto.sniff}
Observe that I am on a simple Windows computer. Nothing fancy. I only have one IP address as far as I understand. I am just asking for my IP-address. If there are folks who use complicated setups then it might be up to them to fix it if it is too confusing. The suggestion, and implementation of it, would help out a lot. For example, when making programs for students. Students who are new might not know enough to solve the problem of finding the IP address and a lot of other small things. It would be too much. Having things automated helps out a lot. This suggestion, to me, is a request of a feature that should have been available from the start.
Thank you for the work that you do.
Comment From: wilkinsona
server.address={this.inet.3.server.auto.sniff}
This looks quite complicated to me and I can't really see the benefit.
By default, there's no address configured and this means that the web server will bind to the wildcard address (0.0.0.0
). This ensures that it can be accessed using any of the host's IP addresses, including localhost
. In terms of ease of use, I don't think it could get much better than this.
If we supported something like this.inet.3.server.auto.sniff
, we'd either have to log the address that we'd magically selected so that people know which address to use, or the user would have to use something like ifconfig
, figure out which is the third address, and then use that. Both feel like a step backwards to me.