简体   繁体   中英

Calling secured drill URL from nodeJS using request

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM