3

I have installed the new Geoserver 2.8.0 and to avoid CORS related errors I wanted to implement a reverse proxy, instead of setting response headers.

In version 2.1.3 there was a <filter-name>Reverse Proxy Filter</filter-name> that you could enable, in the web.xml file.

In version 2.8.0, I could not found such filter. How can I implement a reverse proxy, so I can get rid of CORS related issues?

3

From http://permalink.gmane.org/gmane.comp.gis.geoserver.user/42219

  1. Put content of this archive http://shanbe.hezoun.com/cors.zip into the \webapps\geoserver\WEB-INF\classes folder.
  2. use <filter-class>org.mortbay.servlets.CrossOriginFilter</filter-class> insteand of <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>

You can put follwing conf. inside the \webapps\geoserver\web.xml to allow CORS requests from all domains:

<filter>
  <filter-name>cross-origin</filter-name>
  <filter-class>org.mortbay.servlets.CrossOriginFilter</filter-class>
  <init-param>
    <param-name>allowedOrigins</param-name>
    <param-value>*</param-value>
  </init-param>
</filter>

<filter-mapping>
    <filter-name>cross-origin</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Restart the geoserver and it should work.

|improve this answer|||||
  • 1
    Thanks for the answer. The gmane link is broken, I get The web interface is down for maintenance.As for your solution, you talk about a CORS filter, not a reverse proxy. Anyhow, I was looking for an official solution provided by Geoserver or Jetty. The official CORS solution suggests adding servlets for Jetty7, Geoserver runs Jetty 6 and Jetty 7 to 8 is now EOL – slevin Nov 24 '15 at 12:18
  • 1
    On Geoserver (2.8.0) I also tried unofficial things like first answer here or unofficial proxy. I tried stupid things like copy the old proxy code from Geoserver (2.1.3) web.xml to Geoserver (2.8.0) web.xml. Also on Geoserver (2.8.0) I added http://localhost:8080 on the Proxy Base URL under Global, Settings in the Geoserver (2.8.0) console. Nothing. Either a broken Geoserver, or errors or no proxy. – slevin Nov 24 '15 at 12:32
  • So all Geoserver tricks did not work, CORS filter nor proxy. Plus, I dont usually deploy unofficial solutions. So I used a reverse proxy from node, to Geoserver, with this middleware and works just fine. – slevin Nov 24 '15 at 12:38
  • I am not too in favor of this external CORS zip file, but it's a solution. This solution also solved my need for reverse-proxy, so I might be missing your intent there. – Henry Aloni Nov 24 '15 at 14:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.