Re: Incorrect relative URLs when Tomcat is fronted by Apache?
Thymeleaf asks the Servlet API for the context path (which appears to be "myapp", in this case). Specifically, it does so by executing the "getContextPath()" of the HttpServletRequest object. Once generated, the URL is passed to the HttpServletResponse.encodeUrl() method in order to give an opportunity to URL-rewriting filters to adjust the generated URLs.
So if you observe a difference between how your context is computed with and without an HTTPd acting as proxy, it could be because you have some kind of URL Rewriting filter in place at your Tomcat reading X-Proxy HTTP headers coming from the proxy, or maybe because you have some kind of URL-matching-and-rewriting module in HTTPd rewriting the URLs in your HTML payload.
As for Thymeleaf, all these context-related computations are done by calling methods in the Servlet API itself, so any influence in the obtained values will come from external influences.