[OpenLayers-Users] WFS ProxyHost

Christopher Schmidt crschmidt at metacarta.com
Tue Feb 17 20:47:05 EST 2009


On Tue, Feb 17, 2009 at 10:23:30PM -0300, Raphael Saldanha wrote:
> Thanks Arnd,
> 
> But not working... and I'm having the same problemn with GetFeatureInfo
> link...

The same origin policy is simple:

 * Look at the HTML page URL. Usually (unless you're in frames) this 
   will be your 'origin'. It has three parts that matter:

    * Scheme (http)
    * domain (example.com)
    * port (usually 'nothing', which equates to 80, but might also be
      8080 or something similar)
 
 * Look at the page you are trying to request with XMLHttpRequest.
 * Compare the three things above.
 * IF any of them don't match, you an't make a request.

The way that proxyhost works, is it allows you to say:

 "OpenLayers Request Library, Don't talk directly to remote.com, talk
 through /cgi-bin/proxy.cgi?url= instead."

Then, OpenLayers internally speaks to:

  /cgi-bin/proxy.cgi?url=http://remote.com/

Now, from the browser perspective, you are opening
http://example.com/cgi-bin/proxy.cgi -- scheme, domain, and port match,
so it's allowed. (It doesn't care *what* proxy.cgi does in the
background.)

There are a couple problems that are common:

 1. proxy script not set up correctly. This is unrelated to OpenLayers,
    but a common situation. Open
    http://example.com/cgi-bin/proxy.cgi?url=http://remote.com/ . If you
    don't get remote.com's website back, then your proxy isn't
    configured corectly. (Substitute 'remote.com' for the domain and
    port you wish to access, of course.)

 2. Proxy script not referenced corectly. A common mistake is to forget
    the ?url= when using the default proxy script, or to put
    http://example.com:8080/cgi-bin/proxy.cgi? in when using
    http:?/example.com as your origin.

 3. Passign a URL that the proxy can't access to the proxy. if your
    proxy is on http://example.com/, http://localhost/ is *not* the same
    thing as it is to your computer. Pretend you are on the computer that
    the proxy is running on, and imagine what requesting the URL will do. 

Note that none of these is 'problems in OpenLayers'.

> I'm starting to think why use Openlayers... this ProxyHost is a really
> bitch.

Oh? And you know of some other client-side only library that makes this
work more cleanly?

This is not some arbitrary restriction on the part of OpenLayers. This
is a built in security restriction in JavaScript. Any clientside library
will have similar problems. Swearing at software won't change that.

If you want help with the software you are using it, insulting it to the
developers is *not* the way to go.

Best Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list