<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Authorization for Ambari REST-API does not work when using localhost in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183451#M75594</link>
    <description>&lt;P&gt;I am setting up a test cluster and have some issues with the Ambari REST-API. I get a 403 error whenever I use localhost, but it works when I use FQDN.&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;curl -u admin:admin -H "X-Requested-by:ambari" -i -k -X GET &lt;A href="https://&amp;lt;FQDN&amp;gt;:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/" target="_blank"&gt;https://&amp;lt;FQDN&amp;gt;:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This does not work:&lt;/P&gt;&lt;P&gt;curl -u admin:admin -H "X-Requested-by:ambari" -i -k -X GET &lt;A href="https://127.0.0.1:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/" target="_blank"&gt;https://127.0.0.1:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The latter returns:&lt;/P&gt;&lt;P&gt;HTTP/1.1 403 Forbidden&lt;/P&gt;&lt;P&gt;Cache-Control: no-cache &lt;/P&gt;&lt;P&gt;Pragma: no-cache
Content-Type: text/html; charset=utf-8 &lt;/P&gt;&lt;P&gt;Proxy-Connection: close
Connection: close
Content-Length: 606
curl: (56) Received HTTP code 403 from proxy after CONNECT&lt;/P&gt;&lt;P&gt;We have other clusters where the setup looks identical to me and calls using FQDN and localhost works just fine. I can't figure out why it does not work in this case.&lt;/P&gt;&lt;P&gt;I need localhost to work because commands like &lt;STRONG&gt;&lt;EM&gt;ambari-server sync-ldap&lt;/EM&gt; &lt;/STRONG&gt;are using the REST-API with localhost behind the scenes. Currently when I run ambari-server sync-ldap --groups=/root/groups.txt I get:&lt;/P&gt;&lt;P&gt;Syncing specified users and groups.ERROR: Exiting with exit code 1.
REASON: Sync event creation failed. Error details: &amp;lt;urlopen error Tunnel connection failed: 403 Forbidden&amp;gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2018 17:16:17 GMT</pubDate>
    <dc:creator>johan_lund</dc:creator>
    <dc:date>2018-03-09T17:16:17Z</dc:date>
    <item>
      <title>Authorization for Ambari REST-API does not work when using localhost</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183451#M75594</link>
      <description>&lt;P&gt;I am setting up a test cluster and have some issues with the Ambari REST-API. I get a 403 error whenever I use localhost, but it works when I use FQDN.&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;curl -u admin:admin -H "X-Requested-by:ambari" -i -k -X GET &lt;A href="https://&amp;lt;FQDN&amp;gt;:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/" target="_blank"&gt;https://&amp;lt;FQDN&amp;gt;:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This does not work:&lt;/P&gt;&lt;P&gt;curl -u admin:admin -H "X-Requested-by:ambari" -i -k -X GET &lt;A href="https://127.0.0.1:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/" target="_blank"&gt;https://127.0.0.1:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The latter returns:&lt;/P&gt;&lt;P&gt;HTTP/1.1 403 Forbidden&lt;/P&gt;&lt;P&gt;Cache-Control: no-cache &lt;/P&gt;&lt;P&gt;Pragma: no-cache
Content-Type: text/html; charset=utf-8 &lt;/P&gt;&lt;P&gt;Proxy-Connection: close
Connection: close
Content-Length: 606
curl: (56) Received HTTP code 403 from proxy after CONNECT&lt;/P&gt;&lt;P&gt;We have other clusters where the setup looks identical to me and calls using FQDN and localhost works just fine. I can't figure out why it does not work in this case.&lt;/P&gt;&lt;P&gt;I need localhost to work because commands like &lt;STRONG&gt;&lt;EM&gt;ambari-server sync-ldap&lt;/EM&gt; &lt;/STRONG&gt;are using the REST-API with localhost behind the scenes. Currently when I run ambari-server sync-ldap --groups=/root/groups.txt I get:&lt;/P&gt;&lt;P&gt;Syncing specified users and groups.ERROR: Exiting with exit code 1.
REASON: Sync event creation failed. Error details: &amp;lt;urlopen error Tunnel connection failed: 403 Forbidden&amp;gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 17:16:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183451#M75594</guid>
      <dc:creator>johan_lund</dc:creator>
      <dc:date>2018-03-09T17:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Authorization for Ambari REST-API does not work when using localhost</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183452#M75595</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/69430/johanlund.html" nodeid="69430"&gt;@Johan Lund&lt;BR /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Can you pelase add the "-iv" flag to the curl call.  I am suspecting that it may be a Proxy issue.  So when you use FQDN then your requests might be passing via some proxy server.&lt;/P&gt;&lt;PRE&gt;# curl -iv -u admin:admin -H "X-Requested-by:ambari" -i -k -X GET &lt;A href="https://&amp;lt;FQDN&amp;gt;:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/" target="_blank"&gt;https://&amp;lt;FQDN&amp;gt;:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/&lt;/A&gt;

AND

# curl -iv -u admin:admin -H "X-Requested-by:ambari" -i -k -X GET &lt;A href="https://127.0.0.1:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/" target="_blank"&gt;https://127.0.0.1:8443/api/v1/clusters/&amp;lt;CLUSTERNAME&amp;gt;/services/&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Looks like your ambari-server host might be having some http proxy settings which is not allowing the "localhost" request to be passed via proxy which is rejecting the request.&lt;/P&gt;&lt;P&gt;Please see if you have any &lt;STRONG&gt;-Dhttps.proxyHost=proxy_name&lt;/STRONG&gt;
&lt;STRONG&gt;-Dhttps.proxyPort=xxxx  &lt;/STRONG&gt;configured on your ambari server host like in&lt;STRONG&gt; "~/.bash_profile", "~/.profile" or Or in "~/.bashrc" &lt;/STRONG&gt;&lt;BR /&gt;Please check if you have any OS level setting to define proxy host and Non proxy hosts.&lt;BR /&gt;like:&lt;/P&gt;&lt;PRE&gt;export http_proxy
export https_proxy&lt;/PRE&gt;&lt;P&gt; Or may be at  Host environment level  or inside some script like  /var/lib/ambari-server/ambari-env.sh&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.1.5/bk_ambari-administration/content/ch_setting_up_an_internet_proxy_server_for_ambari.html" target="_blank"&gt;https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.1.5/bk_ambari-administration/content/ch_setting_up_an_internet_proxy_server_for_ambari.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;BR /&gt;&lt;A rel="user" href="https://community.cloudera.com/users/69430/johanlund.html" nodeid="69430"&gt;&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 17:34:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183452#M75595</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2018-03-09T17:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Authorization for Ambari REST-API does not work when using localhost</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183453#M75596</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/69430/johanlund.html" nodeid="69430"&gt;@Johan Lund&lt;/A&gt;&lt;/P&gt;&lt;P&gt;May be the following link give more idea on how to use "no_proxy"  at the OS level inside the "~/.profile", "~/.bash_profile", ENV level. Like: &lt;/P&gt;&lt;PRE&gt;no_proxy="127.0.0.1, localhost"&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/questions/120761/ambari-ldap-sync-ldap-issue-with-proxy-getting-502.html" target="_blank"&gt;https://community.hortonworks.com/questions/120761/ambari-ldap-sync-ldap-issue-with-proxy-getting-502.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 18:14:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183453#M75596</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2018-03-09T18:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Authorization for Ambari REST-API does not work when using localhost</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183454#M75597</link>
      <description>&lt;P&gt;Thanks &lt;A href="https://community.hortonworks.com/questions/177280/authorization-for-ambari-rest-api-does-not-work-wh.html#"&gt;@Jay Kumar SenSharma&lt;/A&gt; ! The no_proxy was what was missing, but the curl -iv flag in this answer was what helped me figure out why it worked on one machine but not the other. So I put this as the accepted answer and gave the other one a vote.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 19:23:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Authorization-for-Ambari-REST-API-does-not-work-when-using/m-p/183454#M75597</guid>
      <dc:creator>johan_lund</dc:creator>
      <dc:date>2018-03-09T19:23:27Z</dc:date>
    </item>
  </channel>
</rss>

