title: Accessing Jira REST api running behind apache proxy
body: <p>I am trying to connect to Jira REST API running behind apache proxy. I tried to use python-jira module for this task and it worked fine as far as I was connecting to Jira directly, bypassing apache proxy authorization. However, with apache proxy up I am steadily getting "Err: 401 Unauthorized" error.</p>
  
  <p>the problem is that I need to provide authorization credentials twice, one for proxy and one for Jira. </p>
  
  <p>All tests had been done on my local VM.</p>
  
  <ul>
  <li>apache proxy is running on standard port 80 and redirects 127.0.0.1/jira to 127.0.0.1:8080/jira</li>
  <li>jira us running on port 8080 </li>
  </ul>
  
  <p>Here is the working curl command where:</p>
  
  <ul>
  <li>jirauser - jira user to use for authorization jirapass </li>
  <li>jirapassword to use for authorization </li>
  <li>dGVzdDp3d3c= - is base64 encoded proxyuser:proxypass string</li>
  </ul>
  
  <p>it is actually running and producing results</p>
  
  <pre><code>curl -u 'jirauser:jirapass' -X GET -H "Authorization: Basic dGVzdDp3d3c=" -H "Content-Type: application/json" "http://127.0.0.1/jira/rest/api/2/search?jql=key=DEV4"
  </code></pre>
  
  <p>for the python-jira module I think that I need to tweak 'options' parameter to add to 'headers' list the "Authorization: Basic dGVzdDp3d3c=" but somehow it doesn't work.</p>
  
  <pre><code>from jira import JIRA, JIRAError
  import sys
  
  username="Jira_username"
  password="Jira_password"
  
  jira_options = {
     'server': 'http://127.0.0.1/jira',
     'verify': True,
      'headers' : {
                          'X-Atlassian-Token': 'no-check',
                          'Cache-Control': 'no-cache',
                          'Content-Type': 'application/json',
                          'Authorization': 'Token token="dGVzdDp3d3c\="'
                  }
  }
  try:
       jira = JIRA(
                   options    = jira_options,
                   basic_auth = (username,password),
                   validate   = True,
              )
  
  except JIRAError as e:
       print("Failed in Jira connection initialisation with error [%s]" % e)
       sys.exit()
  </code></pre>
  
  <p>I also tried to do a direct call with requests librarty</p>
  
  <p>r = requests.get('<a href="http://127.0.0.1/jira/rest/api/2/search?jql=key=DEV4" rel="nofollow noreferrer">http://127.0.0.1/jira/rest/api/2/search?jql=key=DEV4</a>',auth=('jirauser','jirapass'),headers={'Content-Type': 'application/json','Authorization': "Basic %s" % "dGVzdDp3d3c="})</p>
  
  <p>but the result again was: 401 Error</p>
  
  <p>I am getting really confused on why curl command works but python code fails what is wrong here? (since curl is working I assume this is not an issue in environment setup)</p>