如何在 WSO2 API 管理器中配置代理服务器?

how to configure proxy server in WSO2 API manager?

WSO2 API Manager Docs - 该文档讨论了如何设置代理和端口,但没有讨论使用代理服务器进行身份验证所需的用户名和密码。没有它,我会收到代理身份验证错误。如何提供代理的用户名和密码?

WSO2 ESB 有很好的文档记录here。这同样适用于 WSO2 API 经理。按照提供的文档,在配置 axis2.xml 之后,您必须在 API 突触配置中的发送中介之前添加以下属性(位于 $AM_HOME/repository/deployment/server/synapse-configs/default/api/admin--Hello_v1.0.0.xml).

<property name="Proxy-Authorization" expression="fn:concat('Basic ', base64Encode('userName:password'))" scope="transport"/>
<property name="POST_TO_URI" value="true" scope="axis2"/>

完整的 API 突触配置如下所示;

<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
     name="admin--Hello"
     context="/hello"
     version="1.0.0"
     version-type="url">
   <resource methods="POST GET OPTIONS DELETE PUT"
             url-mapping="/*"
             faultSequence="fault">
      <inSequence>
         <filter source="$ctx:AM_KEY_TYPE" regex="PRODUCTION">
            <then>
            <property name="Proxy-Authorization" expression="fn:concat('Basic ', base64Encode('userName:password'))" scope="transport"/>
            <property name="POST_TO_URI" value="true" scope="axis2"/>
               <send>
                  <endpoint name="admin--Hello_APIproductionEndpoint_0">
                     <http uri-template="http://echo.jsontest.com/key/value/one/two"/>
                  </endpoint>
               </send>
            </then>
            <else>
               <sequence key="_sandbox_key_error_"/>
            </else>
         </filter>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </resource>
   <handlers>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
         <property name="id" value="A"/>
         <property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
      <handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
         <property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
      </handler>
      <handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
   </handlers>
</api>

请务必更改上面Proxy-Authorization属性中的用户名和密码。