我在尝试着 :
设置一个子域,其中的根路径/
将代理本地 tomcat 正在运行的 thymeleaf + spring boot 应用程序http://localhost:8080/myuiapp/
,
有了灵活性,我可以改变的背景下路径/application
或/demo
或/anything
没有任何代码库或Tomcat配置的变化在未来的(只有Apache的配置变化)。
我面临的问题是:- thymeleaf 在独立的 tomcat8 上部署时不会更改上下文名称。(我知道上下文路径属性只影响嵌入式 tomcat 服务器)
所以th:href="@{/assets/vendors/global/vendors.bundle.css}"
像href=/myuiapp/assets/vendors/global/vendors.bundle.css
往常一样计算。
这是我尝试过的虚拟主机配置之一:
<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>
我尝试了以下几件事:
1) Apache 向应用程序和应用程序发送标头
SSLProxyEngine on
ProxyPreserveHost on
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
server.use-forward-headers=true
2)手动设置上下文路径
System.setProperty("server.servlet.context-path", contextPath)
3) Thymeleaf 中的服务器相关 URL -链接(它解决了我的第一个问题 Root/
上下文路径但不是/any
上下文路径)
<a th:href="@{~/billing-app/showDetails.htm}">
当我们在 thymeleaf 识别的独立 tomcat 上部署时,需要您的帮助来设置动态上下文名称。
我有一个类似的问题。我在 html 文件中有以下行
<link rel="stylesheet" th:href="@{/css/stylesheet.css}"/>
并且在 找到http://localhost:8321/css/disclaimer.css
并正确应用了样式表(注意路径上缺少应用程序名称)。然而,在生产中,到 css 的新链接是https://example.com/app-name/css/stylesheet.css
但在 html 中它仍然错误地指向https://example.com/css/stylesheet.css
为了解决这个问题,我必须/
像这样从 href 中删除首字母:
<link rel="stylesheet" th:href="@{css/stylesheet.css}"/>
并且在本地和生产中都应用了 css。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句