英文:
Open Liberty 20.0.0 I need URL forwarding for context_root in server.xml
问题
I am using an open liberty to deploy a war using the application tag in the server.xml. I am required to change the context_root for an application but I want the current context root to redirect to the new url. Alternatively, if it were possible, I could use two context roots for the same app. I cannot find the answer in their documentation.
<application id="demo" location="demo-0.0.3-SNAPSHOT.war" name="demo" context-root="/test"></application>
What are my options here for making changing /test
to /newroot
where my.host/test
will redirect to my.host/newurl
from within the server.xml?
英文:
I am using an open liberty to deploy a war using the application tag in the server.xml. I am required to change the context_root for an application but I want the current context root to redirect to the new url. Alternatively, if it were possible, I could use two context roots for the same app. I cannot find the answer in their documentation.
<application id="demo" location = "demo-0.0.3-SNAPSHOT.war" name="demo" context-root="/test"></application>
What are my options here for making changing /test to /newroot where my.host/test will redirect to my.host/newurl from within the server.xml?
答案1
得分: 1
无法将单个war文件绑定到两个上下文根。一些选项可能包括:
- 将应用程序部署两次,每次在一个上下文根下。这可能不是一个好主意,因为您将需要双倍的资源。
- 在前面使用一个Web服务器,并在将请求转发到Liberty之前配置它以进行URL重写。
- 部署第二个war文件,绑定到旧的上下文根,其中包含一个发送重定向到新上下文根的servlet。
我建议升级到更新的Open Liberty版本,因为20.0.0已经有三年了,而且在那之后有很多修复,包括安全修复。
英文:
It is not possible to bind a single war file to two context roots. A few options would be:
- Deploy the application twice, once at each context root. This is probably not a good idea because you'll need double the resources.
- Use a web server in front and configure it to url rewrite before forwarding to Liberty
- Deploy a second war file bound to the old context root that has a servlet that sends a redirect to the new on.
I would recommend upgrading to a newer release of Open Liberty since 20.0.0 is three years old now and there are a lot of fixes since then including security fixes.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论