Friday, 2 November 2018

openlayers 2 - GeoExplorer provokes "401 Unauthorized" request and lacks login


Currently I have a login problem with my deployed GeoExplorer. Everything works fine in debug mode on my local VM with the geoserver from my remote server connected. Firebug gives the following output when loading GeoExplorer.


GET http://localhost:9080/geoserver/ows?SERVICE=WMS&REQUEST=GetCapabilities&TILED=true&VERSION=1.1.1 200 OK 140ms XMLHttpRequest.js (Zeile 220)

GET http://localhost:9080/geoserver/pdf/info.json 200 OK 18ms XMLHttpRequest.js (Zeile 220)

However, once I deploy GeoExplorer and move it to my remote server the login button on the upper right doesn't appear anymore. Instead the basic authorization window "GeoServer Realm" pops up and Firebug shows the following "401 Unauthorized" message:



GET http://Server_IP/geoserver/ows?SERVICE=WMS&REQUEST=GetCapabilities&TILED=true&VERSION=1.1.1 200 OK 227ms GeoExplorer.js (Zeile 396)

GET http://Server_IP/geoserver/pdf/info.json 200 OK 75ms GeoExplorer.js (Zeile 396)

GET http://Server_IP/geoserver/rest/imports 401 Unauthorized 202ms GeoExplorer.js (Zeile 396)

"NetworkError: 401 Unauthorized - http://Server_IP/geoserver/rest/imports"

The same problem applies to the GeoExplorer that was originally installed with the OpenGeoSuite, so it rather seems to stem from the server configuration instead of the deployment process.


I've tried various things in GeoServer security setup and found threads with similar symptoms, but couldn't find a solution for us yet. Maybe someone has another useful hint?!



Another idea: Can I configure the deployed GeoExplorer that it requests GeoServer over localhost instead of the server IP? Could this help?



Answer



Don't do a redirect. Using Apache's ProxyPass and ProxyPassReverse is proven to work fine. Also make sure to set proxy url to the proxied external url in the GeoServer config UI, under Settings - Global - Proxy Base URL. Here is an example for ProxyPass and ProxyPassReverse:


ProxyRequests Off

Order deny,allow
Allow from all

ProxyPass /geoserver http://localhost:8080/geoserver
ProxyPassReverse /geoserver http://localhost:8080/geoserver

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...