'Tomcat: Redirect a Rest Call and use part of the URL to build the parameters

I have an Apache Tomcat server and I need a solution (inside or outside tomcat) to transform the Rest call for instance from "/equipment/instance/{id}/state" to "/myObjects/myInstance/state?id={id}". Is there an easy way to do this?

Thanks!



Solution 1:[1]

I added an Nginx server as a reverse proxy to handle this. I configured a 'rewrite' and it seems to be working well.

Here is the Nginx configuration:

    server {
        listen 81;

       location /mission {
          rewrite ^/equipment/instance/(.*)/state$ http://10.10.10.10:8080/MyServer/myObjects/myInstance/state?testInput=$1 redirect;
       }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1