Fix (or manage) redirects in Web Adaptor

5017
3
Jump to solution
07-12-2017 04:56 PM
BrianWilson
Occasional Contributor II

I have a Web Adaptor behind an nginx proxy. When I am outside here on the Big Bad Internet, I want it behind the proxy. My proxy apparently does the right thing, because when I hit https://bellman.wildsong.biz/arcgis/home it sends the request along to my hidden https://web-adaptor.arcgis.net/arcgis/home and I get the correct front door of ArcGIS Enterprise.

Then when I click through to log in, it redirects to https://web-adaptor.arcgis.net/arcgis/home/signin.html  and thus it fails. How do I keep Web Adaptor from rewriting the URL to one that is unreachable? Is there a place to configure it to send back redirects that work?

I am thinking the response comes directly back from Web Adaptor and it knows nothing of the proxy, so it's doing what it feels is the right thing. Maybe I have to teach nginx to tell W.A. something in its headers?

Thanks -- Brian

0 Kudos
1 Solution

Accepted Solutions
RandallWilliams
Esri Regular Contributor
3 Replies
RandallWilliams
Esri Regular Contributor
BrianWilson
Occasional Contributor II

THANKS I knew there was a doc I was not finding. It seems to work now. I set nginx as a reverse proxy with a few additional lines as suggested in the nginx documentation. The config added to nginx now looks like this:

    location /arcgis/ {
       proxy_pass https://laysan.wildsong.biz/arcgis/;
       proxy_set_header X-Forwarded-Host $host:$server_port;
       proxy_set_header X-Forwarded-Server $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }

See https://www.nginx.com/resources/wiki/start/topics/examples/likeapache/

Then I set properties on Portal to look like this:

 {"WebContextURL":"https://bellman.wildsong.biz/arcgis"}

It's no longer sending me off to the internal address. On the first load it gave an error which I have seen a couple times before where the contents of the screen where the login/password form comes up instead contains and error message about a redirect uri. I reloaded the page and it has worked since.

Harald_ØysteinLund1
Esri Contributor

Hi, I have a customer that uses nginx as a proxy server in DMZ, and acessing upstream IIS server in the internal network running webadaptor for ArcGIS Portal. When we use curl with following call:

curl -k https://<ip>/agsportal

it returns 
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="https://community.esri.com/agsportal/home">here</a>.</h2>
</body></html>
adding -L
works, Then we are prompt for login
So using the external URL (DNS) https://www.acme.com/agsportal end up with 502 Bad gateway. 
Is this because of the Object Moved to?
Should 

location /agsportal/ {
       proxy_pass https://<ip>/agsportal/;
       proxy_set_header X-Forwarded-Host $host:$server_port;
       proxy_set_header X-Forwarded-Server $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }

Should I add handling redirect from the webadaptor server?

location /agsportal/ {
       proxy_pass https://<ip>/agsportal/;
       proxy_set_header X-Forwarded-Host $host:$server_port;
       proxy_set_header X-Forwarded-Server $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
       proxy_intercept_errors on;        error_page 301 302 307 = @handle_redirects;     }      location @handle_redirects {         set $saved_redirect_location '$upstream_http_location';         proxy_pass $saved_redirect_location;     }
0 Kudos