External nginx ( outside openshift cluster) to proxy openshift routes and Linux servers

36 Views Asked by At

We have spring boot service (test-api) deployed on 4 Linux servers (Redhat 7.x). We are currently using external nginx as reverse proxy in order to route and load balance between 4 servers.

As part of cloud migration to openshift, we have deployed test-api to openshift cluster PODs and we can easily access its APIs with openshift route URLs.

Our plan is to gradually migrate API from Linux server to openshift cluster. During migration we are planning to load balance API between Linux servers and openshift cluster PODS.

Can we use existing external nginx ( outside openshift cluster) to manage both Linux server routes as well as openshift routes ?

External Nginx configuration (Outside openshift cluster) :



    upstream testapiservers {

        server test-api-host:8097;  -- linux server, works
        server namespace.cluser:443   -- dns for openshift cluster , does not work

    } 
    server {
      
        location ~ ^/test-api/(.*) {    
            proxy_pass   https://testapiservers/test-api/;  
        }
    }

Case 1 : upstream testapiservers works if we only specify linux server host and ip combination.

Case 2 : If we do not use upstream testapiservers and directly use openshift route urls under location then below setup works.



    location ~ ^/test-api/(.*) {    

        proxy_pass   openshift_route_url_for_test_api;

    }

Is there any way to configure nginx location for API deployed on linux server as well as API deployed on openshift cluster simultaneously ?

If not possible, how to solve this problem with minimal changes ?

0

There are 0 best solutions below