Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to test external rest api?

Jonnada Kiran February 8, 2018

Hi all,

I wrote a irule to divert all external rest api traffic to a particular node. But, dont know how to test it. Can someone please help me with that ?

 

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Craig Castle-Mead
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 18, 2018

Working with apps behind load balancers before, I've found it helpful when the server has added a small HTTP header that indicates the node it's coming from. For security reasons you may not want to make it as simple as 1,2,3,4 - but maybe obfuscate it a little bit and use a random string that your team knows what node is processing the request. This means you can view it in the browser itself instead of logging in to the node(s) to see what requests it's handling.

http://nginx.org/en/docs/http/ngx_http_headers_module.html - example to do this with Nginx. Adjust as necessary for your specific environment.

 

CCM

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2018

I presume you are probably following this guide: https://confluence.atlassian.com/enterprise/traffic-distribution-with-atlassian-data-center-895912660.html

I believe there is a way you can see if these REST API calls are being diverted as expected.  Try these steps:

  1. Login directly to the specific node that you want to divert this traffic to. (in order to do this, you might need to make sure this node has a separate connector that bypasses your load balancer.  One way is to follow the steps in How to bypass a Proxy and SSL to test network connectivity.  And then connect to this node over that local address/port number, such as hostname:9999 instead of the address of your load balancer such as jiradatacenter.example.com .)
  2. Sign in as a Jira admin, and navigate to Gear Icon -> System -> Security -> User Sessions. (This page shows you all the user sessions connected to this node)  You can also reach this by going to [hostname:portnumber]/secure/admin/CurrentUsersList.jspa
  3. Try then to open a command prompt / terminal session
  4. Use a utility like curl to make a REST call directly, example command such as:
    curl -D- -u username:password -X GET -H "Content-Type: application/json" http://jiradatacenter.example.com/rest/api/2/issue/createmeta
  5. Check the page on step 2.

If this is working that node will indicate that there is a specific rest call being made to this node.   Since this call did not request the login.jsp page, we know this call is not be originated by a web login to Jira.  In this case, when you make a curl call, it is purely a REST request to Jira datacenter.   We should see that specific node identifying this as a type=rest with the username you defined in the curl call, and the ip address this originated from.  Example screenshot below.

restcalltest1.png

If you don't see this specific call, you might want to login to the other nodes in a similar manner to see if you can track down this specific call to see which node it was directed to.

Jonnada Kiran February 9, 2018

when HTTP_REQUEST {

set referrer_host [URI::host [HTTP::header value Referer]]

log local0. "Host: [HTTP::host]"
log local0. "uri: [HTTP::uri]"
log local0. "path: [HTTP::path]"
log local0. "referrer: $referrer_host"
log local0. "referrer: referrer_host"

if

{ $referrer_host equals "jiratest.corp.chartercom.com" and [string tolower [HTTP::uri]] contains "/rest/" }

{
pool JIRA-test-pool
}

if

{ not $referrer_host equals "jiratest.corp.chartercom.com" and [string tolower [HTTP::uri]] contains "/rest/" }

{

if

{ [string tolower [HTTP::uri]] equals "/login.jsp" }

 

{ pool JIRA-test-pool }

else

{ pool JIRA-test-external-pool }

}
pool JIRA-test-pool
}

 

I implemented this irule. But still I can't see anything in the access-log 

TAGS
AUG Leaders

Atlassian Community Events