It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to test external rest api?

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

0 votes
Andy Heinzer Atlassian Team Feb 09, 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.

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 

0 votes

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Data Center

Calling Community members who have upgraded to Data Center (or are thinking about it)

Hey Community, my name is Jacob and I’m a Product Marketing Manager on the Data Center team. We want to hear from you! We understand that the move to our Data Center products doesn’t happen overnight...

133 views 6 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you