I am trying to :
setup a sub domain, in which root path
/
will proxy local tomcat's running thymeleaf + spring boot app athttp://localhost:8080/myuiapp/
,With a flexibility that I can change the context path to
/application
or/demo
or/anything
in future (with just apache config changes) without any codebase or tomcat config changes.
The problem I'm facing is:- thymeleaf is not changing context name when deployed on standalone tomcat8. (I got to know that context path property affect only in embedded tomcat server)
So th:href="@{/assets/vendors/global/vendors.bundle.css}"
is computed as href=/myuiapp/assets/vendors/global/vendors.bundle.css
always.
Here's one of the virtual host config that I've tried:
<VirtualHost _default_:443>
ServerName foo.domain.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/foo.domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/foo.domain.com/privkey.pem
ProxyPreserveHost On
ProxyPass / http://localhost:8080/myuiapp/
ProxyPassReverse / http://localhost:8080/myuiapp/
ProxyPass /newapp/ http://localhost:8080/myuiapp/
ProxyPassReverse /newapp/ http://localhost:8080/myuiapp/
</VirtualHost>
I have tried the following things:
1) Apache sending headers to application and application respecting those headers
SSLProxyEngine on
ProxyPreserveHost on
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
server.use-forward-headers=true
2) Setting context path manually
System.setProperty("server.servlet.context-path", contextPath)
3) Server-relative URLs in Thymeleaf - link (It solves my first problem of Root /
context path but not /any
context path)
<a th:href="@{~/billing-app/showDetails.htm}">
Need your help in setting dynamic context-name, when we deploy on standalone tomcat which is recognised by thymeleaf as well.