Configure proxy

2328
7
10-20-2016 09:43 AM
CCWeedcontrol
Occasional Contributor III

I am trying to config a proxy. I have features that are hosted on arcgis online. I have imagery with lables, world transportation, usa Cropland and a feature layer on a map on arcgis online that i set as my map on Web AppBuilder for Arcgis. I created a web application with Web AppBuilder for Arcgis. I download the application and move the app folder to wwwroot folder. I download the proxy file from github.com/Esri/resource-proxy/releases. I copied the DotNet folder in the wwwroot folder and i converted the folder to an application and set applicaiton pool to ASP.NET V4.0. I then opened the proxy.config and entered the services as follows. 

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
mustMatch="true">
<serverUrls>
<serverUrl url="http://services.arcgisonline.com"
matchAll="true"/>


<serverUrl url="http://XXXXXXXXXX.maps.arcgis.com"
clientId="XXXXXXXXXX"
clientSecret="XXXXXXXXXXXXXXXXXXXX"
oauth2Endpoint="https://XXXXXXXXXX.maps.arcgis.com/sharing/oauth2/"
matchAll="true">
</serverUrl>

<serverUrl url="https://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest/services"
clientId="XXXXXXXXXX"
clientSecret="XXXXXXXXXXXXXXXXXXXXf"
oauth2Endpoint="https://XXXXXXXXXX.maps.arcgis.com/sharing/oauth2/"
matchAll="true"/>


</serverUrls>


</ProxyConfig>

<!-- See https://github.com/Esri/resource-proxy for more information -->

my config.json parameters 

"wabVersion": "2.1",
"isTemplateApp": true,
"isWebTier": false,
"httpProxy": {
"useProxy": true,
"url": "",
"alwaysUseProxy": false,
"rules": [{
"urlPrefix": "http://XXXXXXX.maps.arcgis.com/sharing/rest",
"proxyUrl": "http://XXXXX.XXXXXXXX.XXX/DotNet/proxy.ashx"
},
{
"urlPrefix": "http://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest/services",
"proxyUrl": "http://XXXXX.XXXXXXXX.XXX/DotNet/proxy.ashx"
}
]

}
}

I get the following error.

XMLHttpRequest cannot load http://XXXXX.XXXXXXXX.XXX/DotNet/proxy.ashx?http://XXXXXX.maps.arcgis.com/sharing/rest/portals/self?f=json&dojo.preventCache=1476978719639. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
init.js:89 n {message: "Unable to load http://XXXXX.XXXXXXXX.XXXg/DotNet/pr…?f=json&dojo.preventCache=1476978719639 status: 0", response: Object, status: 0, responseText: "", xhr: XMLHttpRequest…}_ssl: undefinedlog: undefinedmessage: "Unable to load http://XXXXX.XXXXXXXX.XXX/DotNet/proxy.ashx?http://2cweeds.maps.arcgis.com/sharing/rest/portals/self?f=json&dojo.preventCache=1476978719639 status: 0"response: ObjectresponseText: ""stack: (...)get stack: stack()set stack: stack()status: 0xhr: XMLHttpRequest__proto__: Errorw @ init.js:89(anonymous function) @ init.js:88c @ init.js:103d @ init.js:103resolve.callback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105(anonymous function) @ init.js:92h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109n @ init.js:138f @ init.js:142
portalUtils.js?wab_dv=2.1:73 n {message: "Unable to load http:/XXXXX.XXXXXXXX.XXX/DotNet/pr…?f=json&dojo.preventCache=1476978719639 status: 0", response: Object, status: 0, responseText: "", xhr: XMLHttpRequest…}_ssl: undefinedlog: undefinedmessage: "Unable to load http://XXXXX.XXXXXXXX.XXX/DotNet/proxy.ashx?http://XXXXXXX.maps.arcgis.com/sharing/rest/portals/self?f=json&dojo.preventCache=1476978719639 status: 0"response: ObjectresponseText: ""stack: (...)get stack: stack()set stack: stack()status: 0xhr: XMLHttpRequest__proto__: Error(anonymous function) @ portalUtils.js?wab_dv=2.1:73(anonymous function) @ init.js:63c @ init.js:103d @ init.js:103reject.errback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105(anonymous function) @ init.js:867c @ init.js:103d @ init.js:103reject.errback @ init.js:105c @ init.js:104d @ init.js:103resolve.callback @ init.js:105c @ init.js:104d @ init.js:103resolve.callback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105c @ init.js:104d @ init.js:103reject.errback @ init.js:105(anonymous function) @ init.js:92h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109a @ init.js:108h @ init.js:107k @ init.js:107w.reject @ init.js:109n @ init.js:138f @ init.js:142

I can ping the proxy (http://XXXXX.XXXXXXXX.XXX/DotNet/proxy.ashx?ping ) i get 

{ "Proxy Version": "1.1.0", "Configuration File": "OK", "Log File": "Not Exist/Readable"}

with http://XXXXX.XXXXXXXX.XXX/DotNet/proxy.ashxhttps://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest...  i get.

ArcGIS REST Services Directory
Home > servicesAPI Reference
JSON

Folder: /

Current Version: 10.41

Services:
L

HTTP Error 500.19 - Internal Server Error

I need some serious help please.

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

2CDSD 2C,

   You need to understand that:

http://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest/services/DSD_ViewerNew 

https://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest/services/DSD_ViewerNew 

Are considered two different addresses by the proxy and thus you would need to have both urls added to the proxy config.

0 Kudos
CCWeedcontrol
Occasional Contributor III

I added both http and https. i am still getting the same error.

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
mustMatch="true">


<serverUrls>
<serverUrl url="http://services.arcgisonline.com"
matchAll="true"/>


<serverUrl url="https://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest/services"
username="VfKdjecQRxviwDnX"
password="884f5ec5cbd946aca3b4ee14179af35f"
matchAll="true"/>

<serverUrl url="http://XXXXXX.maps.arcgis.com"
username="VfKdjecQRxviwDnX"
password="884f5ec5cbd946aca3b4ee14179af35f"
oauth2Endpoint="https://XXXXXX.maps.arcgis.com/sharing/oauth2/"
matchAll="true">
</serverUrl>


<serverUrl url="http://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest/services"
username="VfKdjecQRxviwDnX"
password="884f5ec5cbd946aca3b4ee14179af35f"

oauth2Endpoint="https://XXXXXX.maps.arcgis.com/sharing/oauth2/
matchAll="true"/>


</serverUrls>
</ProxyConfig>

<!-- See https://github.com/Esri/resource-proxy for more information -->

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

When you go to : http://services6.arcgis.com/885XQwwhV5bcCoLj/ArcGIS/rest/services 

do you get a listing of one or more map services? How are you services shared on AGOL?

0 Kudos
CCWeedcontrol
Occasional Contributor III

yes i see a list of services.

Looking at the developer tools in chrome headers i see 3

http://XXXXXX.maps.argis.com/sharing/rest and https//XXXXXX.maps.argis.com/com/sharing/rest.

The http://XXXXXX.maps.argis.com/sharing/rest  response is red

dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"access":"private","analysisLayersGroupQuery":"title:\"Living Atlas Analysis Layers\" AND owner:esri","basemapGalleryGroupQuery"

I am not sure why i have http and https.

I have looked through my services and can not locate a http.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

What about the portalUrl in your main config.json is it http or https?

0 Kudos
CCWeedcontrol
Occasional Contributor III

http://XXXXXX.maps.arcgis.com

 when i run the application in Chrome i get the Please sign in to access the item onArcGIS Online (item).

How do i find out what "Item" the sign in is referring to?

0 Kudos
MichaelAugust
Occasional Contributor III

you could remove the services one by one from you app possibly, process of elimination

0 Kudos