[GIS] reverse proxy on geoserver

corsgeoserverPROXY

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?

Best Answer

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.