Hello,
Is there a property to let Spring Boot have all its default values, but not share the webpage / static folder by default? I have a project which can be used in multi-node. All nodes are basically the same, but with different configs. I want people not to be able to fetch the webpage from the ...lets call them... helper nodes, but from the gateway only. So gateway: fully normal. others: fully normal minus sharing webpage. Any property for this? New feature?
Comment From: bclozel
The described use case here is not really clear, especially the link with the multi-module nature of your application and the presence of a gateway. I think you might be interested in the spring.resources.static-locations
configuration property if you'd like to restrict the location of static resources served for your application.
For further questions, please share a more elaborate version of this on StackOverflow, as we try to keep this issue tracker for bugs and enhancement requests with more context.
Thanks!
Comment From: Adriansun
Leave out the name "gateway". I just mean that I want one server (node) to serve the webpage and do nothing else. On that webpage there are links to rest-controllers on clones (other node) that are exactly the same, but only some rest-controllers are 'turned on'. I guess that if one takes the address to one of those pages -> now one can load the web-page from that other node - which I do not want.
I tried the: spring.resources.static-locations on the "other nodes" to set the path to something silly. When I tried to get the web-page from one of those nodes the web page did not load. Good! But why am I here? Well because the logger writes out maybe 5-10 rows of something like "could not load / get something something". To have logs filled with hackers (lets just call them hackers) trying to load a page from a server that denies static sharing is not okay. People who wants to mess will fill the logs with junk all over the place. See the issue?
Comment From: bclozel
If you want to completely disable resource handling on an application, you can use spring.resources.add-mappings=false
.
Comment From: Adriansun
Thank you! spring.resources.add-mappings=false returns the 404 page - perfect!
On the side: Can you tell me where I could have found this information before asking? Now knowing about spring.resources.add-mappings and googling it does not qualify as an answer. :)
Comment From: bclozel
You could have found that in the reference documentation (see here and here). If you don't know what to look for, StackOverflow is usually helpful.
Comment From: Adriansun
If you don't know what to look for, StackOverflow is usually helpful.
Thank you and you mean like this (look at the date, point, and comment): https://stackoverflow.com/questions/62600886/disable-sharing-webpage-static-in-spring-boot
Comment From: bclozel
Well crafted questions take more time and skills, but usually are easier to answer to; here's an example of a more focused question that got an answer.
Comment From: Adriansun
Hi there, I hope that it is okay that I write my conundrum here.
It was recommended to me to set: spring.resources.add-mappings=false, so my static content would not be served to users. With Spring Boot 2.4.2 I noticed that it has been deprecated. If I, in IntelliJ, look at what IntelliJ recommends then it suggests: spring.web.resources.add-mappings=false. IntelliJ accepts the later as ok. Here is the kicker; according to ' https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/web/ResourceProperties.html ' both of these properties seems to have been deprecated. Also another thing is that I cannot see any mention of this change at ' https://spring.io/blog/2021/01/14/spring-boot-2-4-2-available-now '.
So what should I do to make sure that one of my micro-services do not serve its static content?
Comment From: wilkinsona
The new property is bound to WebProperties.Resources
.
Also another thing is that I cannot see any mention of this change at https://spring.io/blog/2021/01/14/spring-boot-2-4-2-available-now.
This is a blog post announcing the release of 2.4.2 which is a maintenance release. The change to the properties was made in 2.4.0 and is described in the release notes that are linked to from the blog post announcing 2.4's release.
As Brian requested last year, please ask any follow up questions on Stack Overflow as we prefer to use the issue tracker for only bugs and enhancements.
Comment From: philwebb
@Adriansun The deprections are mentioned in the release notes. You're IDE should also offer the replacement property. In this case the replacement as listed here is spring.web.resources.add-mappings
.
For further questions, please use stackoverflow.com.