Open Liberty 20.0.0 我需要在 server.xml 中为 context_root 进行 URL 转发。

huangapple go评论64阅读模式
英文:

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.

&lt;application id=&quot;demo&quot; location = &quot;demo-0.0.3-SNAPSHOT.war&quot; name=&quot;demo&quot; context-root=&quot;/test&quot;&gt;&lt;/application&gt;

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文件绑定到两个上下文根。一些选项可能包括:

  1. 将应用程序部署两次,每次在一个上下文根下。这可能不是一个好主意,因为您将需要双倍的资源。
  2. 在前面使用一个Web服务器,并在将请求转发到Liberty之前配置它以进行URL重写。
  3. 部署第二个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:

  1. Deploy the application twice, once at each context root. This is probably not a good idea because you'll need double the resources.
  2. Use a web server in front and configure it to url rewrite before forwarding to Liberty
  3. 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.

huangapple
  • 本文由 发表于 2023年4月7日 03:59:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75953322.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定