Use of the AGS API for JS proxy page

Source: Internet
Author: User
Tags oauth

Use of the AGS API for JS proxy page

1. Overview

The proxy page is a request-forward page written in the backend language, deployed on the Web application side. A client request is sent to the proxy page before the proxy page forwards the request to the server for processing, and the server processing results are then forwarded to the client by the proxy page.

There are several scenarios for using proxy pages:

(1) The Server for Web application deployment is different from the server where the service resides, that is, there are cross domains.

(2) Avoid exposing tokens to the client.

(3) Web App end users are non-ArcGIS platform users.

(4) The URL address length limit is exceeded (by default, 2048 characters).

2, Proxy page configuration and use

Depending on the backend language, there are three types of proxy pages: ASP. NET, java/jsp, PHP. See:

Https://github.com/Esri/resource-proxy/releases

2.1. Agent Page Configuration

Copy the extracted Java folder to the Web server, such as Tomcat/wabapps.

(1) Proxy.config configuration

Parameters

Description

Mustmatch=true

Only the matching URLs go to the proxy.

logfile= "Local Absolute path"

The log file storage path.

Loglevel= "severe| warning|info| Config| fine| finer| FINEST "

Log level settings.

Allowedreferers= "Http://server.com/application1,https://server.com/application2"

Only the matching client URL goes to the proxy.

<serverUrl>

Defines the service configuration that requires a proxy.

Url= ""

The root URL can be used, but the matchall needs to be set to false.

Matchall= "true"

Whether it must match.

Username

Used in conjunction with the token service.

Password

Used in conjunction with the token service.

Tokenserviceuri

Token service access address.

ClientId

Used in conjunction with OAuth authentication.

Clientsecret

Used in conjunction with OAuth authentication.

Oauth2endpoint

Used in conjunction with OAuth authentication. Default value: https://www.arcgis.com/sharing/oauth2/

Ratelimit

The maximum number of requests sent by a particular client IP, and the period is defined by Ratelimitperiod.

Ratelimitperiod

The default is 60 minutes.

(2) Canceling the Web server file list feature

To ensure the security of the Proxy.config file, you need to turn off the Web Server file List feature, which can be tested by URL:

Http://[yourmachine]/proxy/proxy.config

2.2, Agent page use

(1) Method 1

ESRICONFIG.DEFAULTS.IO.PROXYURL = "<url_to_proxy>"

EsriConfig.defaults.io.alwaysUseProxy = false;

where Esriconfig need to introduce esri/config modules.

(2) Method 2

Using a proxy rule, which defines the resource URL prefix, uses a proxy page when the request URL matches the prefix defined in the rule.

Urlutils.addproxyrule ({

URLPrefix: "Route.arcgis.com",

Proxyurl: "<url_to_proxy>"

});

where urlutils need to introduce esri/urlutils modules.

2.3. Testing

You can use URL address testing:

Http://[yourmachine]/java/proxy.jsp?http://services.arcgisonline.com/arcgis/rest/services/?f=pjson

?

?

?

Use of the AGS API for JS proxy page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.