Calling secured drill URL from nodeJS using request

130 views Asked by At

I have NodeJS service which is protected and exposed using a load balancer. Need to call the drill Query.JSON API which is projected using j_secuirty_check.

Existing logic: First hit the j_security_check URL with the credentials and receive the cookie. Hit the query.JSON URL with the received cookie in the above step.

Code Snippet:

var options1 = {
    url: 'http://<HOSTNAME>:8047/query.json',
    method: 'POST',
    json: JSON.parse('{ "queryType":"SQL", "query":  "show schemas"}'),
    headers : {
        cookie : setcookie
    }
};

The above method is working without the load balancer. Example:

backend service running on http://localhost:3000
Drill URL: http://<SOMEIP:PORT>/query.JSON 

Issue: The second request is redirecting to login page thought we set cookie received in the previous step.

Example:

backend service running on https://<LOADBALANCER_URL>
Drill URL: http://<SOMEIP:PORT>/query.JSON 

Is this because of https & http protocols or diff domain?

Please share your suggestion.

1

There are 1 answers

0
Sorabh On

In case of load balancer the request might be going to another Drillbit WebServer which doesn't issued the cookie in first step. In which case it will not work, your load balancer should have some concept of sticky session or send the request from a client to same WebServer every time.