Trying to configure the proxy of a Web AppBuilder application

8369
5
04-07-2016 11:23 AM
RobertoOliveira
New Contributor III


Hello,

I'm trying to develop with Web AppBuilder for Developers.

Having a hard time with proxy configuration.

Used the following tutorial, but with no success:

Setting up a Proxy | Support Services Blog

Setting up a proxy with Web AppBuilder Developer Edition | Support Services Blog

My Scenario:

- ArcGIS Server on: https://server.virtual.private:6443/arcgis/manager/

- Portal for ArcGIS on: https://server.virtual.private:7443/arcgis/home/

ArcGIS for Server and Portal for ArcGIS was installed with WebAdaptor, checked the following urls, and everything is working:

http://server.virtual.private/arcgis/rest/services

http(s)://server.virtual.private/arcgis/home/ (working on both protocols)

Services used on app:

http://server.virtual.private/arcgis/rest/services/SampleWorldCities/MapServer

Create a app with default options (default 2d), with map that used the SampleWorldCities service.

Registered the Web App on Portal for ArcGIS and get a App ID and App Secret.

(PS: I not using ArcGIS Online).

I'm using Windows 7 with IIS 7 on my local machine to develop...

installed the proxy on IIS from the following address:

GitHub - Esri/resource-proxy: Proxy files for DotNet, Java and PHP.

Used the DotNet version, converted to Application, set the pool to use .NET 4.0, and tested entering using the url:

http://mymachineip/DotNet/proxy.ashx​​ and got a

{"error": {"code": 400,"message":"This proxy does not support empty parameters."}}

I think this is a OK response

Ok. Following tutorial, registered App on Portal for ArcGIS using the App ID, downloaded the app, put on IIS.

Then, when I try to access, I received a message asking my login and password, because I don't have permission (I don't have configured proxy yet)!

If I enter the username and password of a user of Portal for ArcGIS, everything was working correctly.... so, time to configure the proxy.

Looking at tutorial, I modified proxy.config (from DotNet application) with the following information:

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*" mustMatch="true">
  <serverUrls>
    <serverUrl url="http://services.arcgisonline.com" matchAll="true" />
      
  <serverUrl url="http://server.virtual.private/arcgis/sharing/rest" 
            clientId="wWUNYgmDOth4p4Qx" 
               clientSecret="79818e1d6f2a4a5ba6b94a7d2bf85fb0" 
               matchAll="true" />
   
    <serverUrl url="http://server.virtual.private/arcgis/rest/services" 
            username="siteadmin" 
    password="secret" 
    matchAll="true" />
    
  </serverUrls>
</ProxyConfig>

I really don't know what put on the url, clientID and clientSecret (on clientID and clientSecret I have put the same information that was on Portal for ArcGIS - App ID and App Secret - all the documentation I read were not clear to tell me what should I put).

In config.json (of web app), I have put the following information:

"httpProxy": {
    "useProxy": true,
    "alwaysUseProxy": false,
    "url": "",
    "rules": [
   {
     "urlPrefix": "http://server.virtual.private/arcgis/sharing/rest",
  "proxyUrl": "http://host-vm/DotNet/proxy.ashx"
   },
   {
     "urlPrefix": "http://server.virtual.private/arcgis/rest/services",
  "proxyUrl": "http://host-vm/DotNet/proxy.ashx"
   }
  ]
  }

Tried again access the app (on IIS with proxy), but still asking for username and password.

Looking at chome dev tools, there's a warning message with following content:

Error: You do not have permissions to access this resource or perform this operation.(…)

Object {server: "http://server.virtual.private/arcgis", tokenServiceUrl: "https://server.virtual.private/arcgis/sharing/generateToken", hasPortal: true}

Any helps?

0 Kudos
5 Replies
RobertoOliveira
New Contributor III

Looking in document - must include oauth2endpoint in the serverurl when using OAUTH2 for WAB · Issue #307 · Esr...​ I included the

oauth2Endpoint="https://server.virtual.private/arcgis/sharing/oauth2"

on proxy.config (DotNet app).

Now, the page was blank, and I see a error 500 on Chrome Dev Tools when the page try to access the following url:

http://host-vm/DotNet/proxy.ashx?http://server.virtual.private/arcgis/sharing/rest/portals/self?f=js...

But first, I will try the URLs of Robert Scheitlin:

1. http://host-vm/DotNet/proxy.ashx?ping:

{ "Proxy Version": "1.1.1-beta", "Configuration File": "OK", "Log File": "Not Exist/Readable"}

2. http://host-vm/DotNet/proxy.ashx?http://server.virtual.private/arcgis/rest/services:

ERROR: The remote certificate is invalid according to the validation procedure.

3. http://host-vm/DotNet/proxy.ashx?https://server.virtual.private/arcgis/rest/services:

{"error": {"code": 403,"message":"Proxy has not been set up for this URL. Make sure there is a serverUrl in the configuration file that matches: https://server.virtual.private/arcgis/rest/services https://server.virtual.private/arcgis/rest/services"}}

4. http://host-vm/DotNet/proxy.ashx?http://server.virtual.private/arcgis/sharing/rest/portals/self?f=js... (The URL that got error after put oauth2Endpoint):

ERROR: The remote certificate is invalid according to the validation procedure.

Now I have two problems...

1: I need a valid certificate? this is just for internal developments! The app will not be published until finished!

2: proxy not working for address beginning with 'https' (see URL 3)

RobertScheitlin__GISP
MVP Emeritus

I don't have any advice on the ssl certificate but for

proxy not working for address beginning with 'https' (see URL 2)

Just add another serverUrl with https to the proxy.config

RobertoOliveira
New Contributor III

Already made changes for this and working...

now only need a solution for a valid SSL!

0 Kudos
SergeiMitakovich
New Contributor II

I had the similar problem. ArcGIS Server, Portal, WAB 2.1, self-signed certificate. All routes are configured, but there is an error. My solution I found here.

I put extra code in proxy.ashx

It was

...

public class proxy : IHttpHandler {

    private static String version = "1.1.1-beta";

    class RateMeter {

...

It became

...

public class proxy : IHttpHandler {
    
    static void Main() {
        System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate{ return true; };
    }

    private static String version = "1.1.1-beta";

    class RateMeter {

...

But you have to be careful with this code, taking into account other applications