Select to view content in your preferred language

How to fix referer with proxy

1470
3
11-22-2022 07:05 AM
MKF62
by
Frequent Contributor

My website used to work, but now it no longer does. I have a custom web map set up with a proxy and I recently tried to publish it after moving our website to a new server and now it's giving me this error message:

 

{"error": {"code": 403,"message":"403 - Forbidden: Access is denied.","details":["message":"Current proxy configuration settings do not allow requests which do not include a referer header."]}}

 

 

I have my proxy code set up like this:

In the javascript web map file:

 

            //Set up the proxy to forward requests for data/geoprocessing tools
            urlUtils.addProxyRule({
                urlPrefix: "https://www.mydomain.com",
                //For production environment (publishing)
                proxyUrl: "/myAppName/proxy/proxy.ashx"
            });

 

 

In my proxy.config file:

 

<ProxyConfig allowedReferers="https://www.mydomain.com/*"
             mustMatch="true"
             logFile="proxyLog.txt"
             logLevel="Warning">
	<serverUrls>
		<serverUrl url="https://www.mydomain.com/webadaptor/rest/services/HabitatManagement/HabitatManagement/GPServer"
				   username="username"
				   password="password"
				   matchAll="true"/>
		<serverUrl url="https://www.mydomain.com/webadaptor/rest/services/HabitatMonitoring/HabitatData/MapServer"
				   username="username"
				   password="password"
				   matchAll="true" />
		<serverUrl url="https://www.mydomain.com/webadaptor/rest/services/HabitatMonitoring/HabitatClassification/GPServer"
				   username="username"
				   password="password"
				   matchAll="true" />
		<serverUrl url="https://www.mydomain.com/webadaptor/rest/services/PrintHabitatMaps/PrintHabitatMap/GPServer"
				   username="username"
				   password="password"
				   matchAll="true" />
		<serverUrl url="https://www.mydomain.com/webadaptor/rest/services/ShipData/ShipData/GPServer"
				   username="username"
				   password="password"
				   matchAll="true" />
		<serverUrl url="https://www.mydomain.com/webadaptor/rest/services/Collector/FieldMapsHbData/GPServer"
				   username="username"
				   password="password"
				   matchAll="true" />
	</serverUrls>
</ProxyConfig>

 

 

This is the request header for one of the map services trying to be reached:

 

Screenshot 2022-11-22 095757.png

 

This is the error info:

Screenshot 2022-11-22 100344.png

 

The proxyLog.txt file gives me this error. I'm don't really know anything about networks, but I don't understand why it says I have a null referer yet the request header has a value in referer??:

The Proxy is being called by a null referer. Access denied.

 

0 Kudos
3 Replies
Sage_Wall
Esri Contributor

Hi @MKF62 ,

Does the Referer in your request header https://www.mydomain.com/myAppName/HabitatMap/HabitatJSMap match the one specified in your proxy configuration?  It's possible that when you changed webservers the Referer (web address for your application) changed and would need to be updated in your proxy configuration. Do you have an IT department you can reach out to?  When it comes to network issues every organizations infrastructure is configured differently and these things can be really hard to troubleshoot without being on site.

0 Kudos
MKF62
by
Frequent Contributor

It does match. In my config I use https://www.mydomain.com/*

So that's all the referrer in the request header needs to match, correct? The asterix at the end should take care of the rest.

0 Kudos
JoelBennett
MVP Regular Contributor

In the allowedReferers of my proxy.config file, the servers listed don't have the "https://" prefix, so maybe try just "www.mydomain.com/*"

0 Kudos