I'm quite confused on how to get this proxy working.
I've secured one geoprocessing service called Habitat Management. It is located in the HabitatManagement folder, the service is titled HabitatManagement, and it contains a geoprocessing task called HabitatManagement. Essentially, the url for the secured service looks like this:
https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/HabitatManagement
The actual web mapping application resides inside of a .NET application. The URL of the .NET application is this:
https://www.mydomain.com/appName
The actual web map url is this:
https://www.mydomain.com/appName/HabitatMap/HabitatJSMap
I have my proxy config file set up like so:
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>ProxyConfig</SPAN> <SPAN class="attr-name token">allowedReferers</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.mydomain.com%2FappName%2F*" target="_blank">https://www.mydomain.com/appName/*</A><SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">mustMatch</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>true<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">logFile</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>proxyLog.txt<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">logLevel</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>Warning<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">></SPAN></SPAN>
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>serverUrls</SPAN><SPAN class="punctuation token">></SPAN></SPAN>
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>serverUrl</SPAN> <SPAN class="attr-name token">url</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.mydomain.com%2FmyServer%2Frest%2Fservices%2FHabitatManagement%2F" target="_blank">https://www.mydomain.com/myServer/rest/services/HabitatManagement/</A><SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">username</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>username<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">password</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>password<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">matchAll</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>true<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">/></SPAN></SPAN>
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>serverUrls</SPAN><SPAN class="punctuation token">></SPAN></SPAN>
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"></</SPAN>ProxyConfig</SPAN><SPAN class="punctuation token">></SPAN></SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I have the proxy JS code like this:
urlUtils<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addProxyRule</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
urlPrefix<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.mydomain.com" target="_blank">https://www.mydomain.com</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>
proxyUrl<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.mydomain.com%2FappName%2Fproxy%2Fproxy.ashx" target="_blank">https://www.mydomain.com/appName/proxy/proxy.ashx</A><SPAN>"</SPAN></SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>If I go to the proxy page following this URL:
https://www.mydomain.com/appName/proxy/proxy.ashx
It works as expected, it says "Config File: "OK" Log File: "OK""
When I test this URL, it takes me to the HabitatManagement folder but does not show the services within it, even though the token should be passing the username and password so I can see the services, right? That's issue #1 that I don't understand.
https://www.mydomain.com/appName/proxy/proxy.ashx?https://www.mydomain.com/myServer/rest/services/HabitatManagement
Additionally, when I go the web map and try to access the service, it still makes me login with this message:
Please sign in to access the item on https://www.mydomain.com/myServer (HabitatManagement/HabitatManagement)
If I login, things work fine - it appears the token is generated and appended to the URL as it should be.
If I change the config file serverURL to this (note the extra "HabitatManagement" on the end of the URL):
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>serverUrl</SPAN> <SPAN class="attr-name token">url</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.mydomain.com%2FmyServer%2Frest%2Fservices%2FHabitatManagement%2FHabitatManagement" target="_blank">https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement</A><SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">username</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>username<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">password</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>password<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">matchAll</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>true<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">/></SPAN></SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
and try this URL, the request fails with "Bad Request" error:
https://www.mydomain.com/appName/proxy/proxy.ashx?https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement
and if I test it in the application it still prompts me to login with the same message as before.
I have also tried to change my serverURL to something very general with no luck. Ideally, the serverURL would be more specific than this as there are some services we have that don't require authentication thus do not need to run through a proxy.
<SPAN class="token tag"><SPAN class="token tag"><SPAN class="punctuation token"><</SPAN>serverUrl</SPAN> <SPAN class="attr-name token">url</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fwww.mydomain.com" target="_blank">https://www.mydomain.com</A><SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">username</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>username<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">password</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>password<SPAN class="punctuation token">"</SPAN></SPAN>
<SPAN class="attr-name token">matchAll</SPAN><SPAN class="attr-value token"><SPAN class="punctuation token">=</SPAN><SPAN class="punctuation token">"</SPAN>true<SPAN class="punctuation token">"</SPAN></SPAN><SPAN class="punctuation token">/></SPAN></SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I'm not sure if my proxy is located in the wrong spot, or if my referrer URL is messed up, or if my serverURLs are messed up. How do I access my secured services using the proxy?