We have to use a proxy to send a request to GeoServer. I created a PHP file like this.

OpenLayers.ProxyHost = "proxy.php?url=";

is Openlayers settings.


is my proxy adress. Proxy content is like this.

$headers = array(
    "Content-type: application/xml",
    "Content-type: text/xml",

 $ch = curl_init($_GET['url']);
 curl_setopt($ch, CURLOPT_HEADER, 1);
 curl_setopt($ch, CURLOPT_HTTPGET, 1);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 $output = curl_exec($ch);
 echo $output;

I am using this proxy like:


Which works, such that a web page is opened.

But when I try a GeoServer WMS get query, it gives a NullPointerException error. For example:

http://myip/geoserver/app/wms is returning admin page, but

http://localhost/myapp/proxy.php?url=http://myip/geoserver/app/wms is returning:

HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: application/xml Transfer-Encoding: chunked Date: Wed, 03 Sep 2014 14:18:11 GMT java.lang.NullPointerException null

http://myip/geoserver/app/wms?request=GetCapabilities is returning an XML page, but


is returning plain text result.

  • does your "app" WMS service require different privileges to the global WMS service? It looks like you are explicitly setting the request headers sent to the remote URL (incorrectly - Content-Type can only have a single value) instead of passing the incoming headers straight through. If your browser is sending an auth header it is getting stripped out by the proxy – tomfumb Nov 8 '16 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.