新增代理服务

<p class="shortdesc">若需要配置路由规则时,需进行代理服务管理。</p> <section><div class="tasklabel"><h2 class="doc-tairway">操作步骤</h2></div><ol class="ol steps"><li class="li step stepexpand"> <span class="ph cmd"><span class="ph" id="Add_Agency_services__d21e23">登录应用管理与运维平台。</span></span> </li><li class="li step stepexpand" id="Add_Agency_services__step_wfq_nyc_1sb"> <span class="ph cmd">在左侧导航栏中,选择<span class="ph menucascade"><span class="ph uicontrol">服务治理</span><abbr> > </abbr><span class="ph uicontrol">接入层网关配置</span></span>。</span> </li><li class="li step stepexpand" id="Add_Agency_services__step_wny_nyc_1sb"> <span class="ph cmd">选择进入<span class="ph uicontrol">代理服务</span>页签。</span> </li><li class="li step stepexpand"> <span class="ph cmd">在页面右上角,单击<span class="ph uicontrol">新增代理服务</span>。</span> </li><li class="li step stepexpand"> <span class="ph cmd">在<span class="ph uicontrol">新增代理服务</span>页面,配置参数信息。</span> <div class="itemgroup info"> <ul class="ul" id="Add_Agency_services__ul_sm1_wzc_1sb"> <li class="li"><strong class="ph b">配置基础信息</strong>:填写服务名称。</li> <li class="li"><strong class="ph b">配置上游信息(即后端服务)</strong>:后端服务包括有静态资源、上游集群(即负载均衡)、独立服务。<img class="image" id="Add_Agency_services__image_fmd_41d_1sb" src="https://obs-cn-shanghai.fincloud.pinganyun.com/pacloud/20220910180811-1cfadd8c9997.png" width="800"><table class="table" id="Add_Agency_services__table_ofr_r1d_1sb"><caption></caption><colgroup><col style="width:23.640661938534276%"><col style="width:76.3593380614657%"></colgroup><thead class="thead"> <tr class="row"> <th class="entry" id="Add_Agency_services__table_ofr_r1d_1sb__entry__1"><strong class="ph b">字段名</strong></th> <th class="entry" id="Add_Agency_services__table_ofr_r1d_1sb__entry__2"><strong class="ph b">字段说明</strong></th> </tr> </thead><tbody class="tbody"> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">协议</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">选择上游服务的请求协议,为http或https。</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">服务IP/域名</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">即后端服务的访问IP或域名,值可以为以下方式:1. 上游服务的IP地址2. 上游服务的域名,可以是外部DNS,内网DNS或K8S FQDN域名(只要网络通都可以)3. 上游集群名,即在”上游集群”模块中创建的”集群名称”,支持将匹配的请求转发到对应的上游集群中的节点,实现负载均衡。4. 静态资源,即前端页面,则值必须是localhost。</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">服务端口</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">填写上游服务的服务端口。如果是选择了上游集群,则端口必须是80如果是选择了静态资源,则值必须是5000。</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">路径</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">填写转发到上游服务的请求URL前缀。</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">上游URL</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">该项为根据上面填写的协议、主机名、端口、路径自动生成的上游URL,在KONG进行转发的时候,会把匹配到的请求的相对URL加到该上游URL后面。</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">连接超时</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">kong到后端服务创建连接的超时时间,单位为毫秒。</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">读超时</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">kong从后端读取数据的超时时间,单位为毫秒</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">写超时</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">kong向后端写入数据的超时时间,单位为毫秒</p> </td> </tr> <tr class="row"> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__1 "> <p class="p">重试次数</p> </td> <td class="entry" headers="Add_Agency_services__table_ofr_r1d_1sb__entry__2 "> <p class="p">填写转发到上游服务的时候,如果请求失败,需要尝试重试的次数。可以为0,为0则不重新发送请求到后端服务</p> </td> </tr> </tbody></table></li> <li class="li"><strong class="ph b">配置路由规则</strong>:即对客户端开放的访问路径和请求规则限制,客户端也只能是访问此处定义的访问路径。<img class="image" id="Add_Agency_services__image_g2w_p1d_1sb" src="https://obs-cn-shanghai.fincloud.pinganyun.com/pacloud/20220910180811-129e1465951b.png" width="800"><table class="table" id="Add_Agency_services__table_evr_lzc_1sb"><caption></caption><colgroup><col style="width:35.46099290780141%"><col style="width:64.53900709219857%"></colgroup><tbody class="tbody"> <tr class="row"> <td class="entry"><strong class="ph b">字段名</strong></td> <td class="entry"><strong class="ph b">字段说明</strong></td> </tr> <tr class="row"> <td class="entry"> <p class="p">Host</p> </td> <td class="entry"> <p class="p">即http请求中的host值。如果KONG作为多个虚拟站点提供服务,也就是绑定了多个域名的话,如果需要按域名进行路由和分流,则需要设置该字段,值为<strong class="ph b">对应的域名。</strong>也可以是访问的<strong class="ph b">IP或机器主机名</strong>。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">请求方法</p> </td> <td class="entry"> <p class="p">值为GET, POST, PUT, DELETE等http动作,如果需要按http动作进行路由,则需设置;一般不需要设置。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">请求协议</p> </td> <td class="entry"> <p class="p">该字段值为http或https, 一般默认值为”http,https”, 同时支持http和https协议请求。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">请求路径</p> </td> <td class="entry"> <p class="p">即外部请求路径,该字段为需要匹配的请求的相对URL路径,例如”/api”, “/web”。<strong class="ph b">匹配方式为前置匹配</strong>,即如果设置为/web/则会匹配请求路径为/web/123,/web/666的请求支持正则表达式。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">Header</p> </td> <td class="entry"> <p class="p">即通过Header做请求匹配及转发。v2.x版本支持。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">Cookie</p> </td> <td class="entry"> <p class="p">即通过Cookie做请求匹配及转发。v2.x版本支持。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">客户端IP</p> </td> <td class="entry"> <p class="p">即通过客户端IP做请求匹配及转发(支持网段)v2.x版本支持。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">去除匹配路径</p> </td> <td class="entry"> <p class="p">如果勾选,则转发请求到上游服务的时候,会把匹配到的路径去除掉,把剩下的路径加到上游URL后面。上游URL见”上游信息”配置部分;如果不勾选,则会把原请求的相对URL加到上游URL后面。</p> </td> </tr> <tr class="row"> <td class="entry"> <p class="p">保留主机头</p> </td> <td class="entry"> <p class="p">如果勾选,则转发请求到上游服务的时候,会保留原请求的Host请求头字段;如果不勾选,则在转发请求到上游服务的时候,会把请求的Host请求头字段改写为KONG的IP或主机名。</p> </td> </tr> </tbody></table></li> </ul> </div> </li><li class="li step stepexpand"> <span class="ph cmd">配置完成后,单击<span class="ph uicontrol">确认</span>。</span> </li></ol></section>
以上内容是否解决了您的问题?
请补全提交信息!
联系我们

电话咨询

400-151-8800

邮件咨询

fincloud@ocft.com

在线客服

工单支持

解决云产品相关技术问题