I was looking on Geoserver cross domain support (no-proxy) recently and I
managed to get it working by compiling custom filter for Jetty 6.1.8. The
filter is based on CrossOriginFilter which is supplied with newer versions
of jetty-servlets.jar. I have fixed some white-space bugs and tested it
with OpenLayers 2.12, IE, FF and Chrome.

You can follow the same rules as described here:
http://wiki.eclipse.org/Jetty/Feature/Cross_Origin_Filter but:

1.Do not include the jar. Instead, put content of this archive
http://shanbe.hezoun.com/cors.zip into the
<Geoserver>\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>
3. do not use additional spaces in allowedHeaders defs (like this:
"x-request-with, content-type")

You can put follwing conf. inside the <Geoserver>\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>
      <init-param>
       <param-name>allowedMethods</param-name>
       <param-value>GET,POST</param-value>
      </init-param>
      <init-param>
       <param-name>allowedHeaders</param-name>
       <param-value>x-requested-with,content-type</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.

Regards,
Dusan Fedorcak
------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to