couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Geurts <dennis.geu...@luminis.eu>
Subject Re: External process for httpd_global_handlers
Date Sat, 19 Mar 2011 21:21:12 GMT
Hi Edward,

I guess from your message that you would like to accomplish the following:

- use flash to access data from a CouchDB.

This requires for the CouchDB to serve a file called 'crossdomain.xml' which your flash application
will load first
to verify it's allowed to do so. Flash requires that this file is located at the root of your
HTTP server ( e.g. http://flash.example.org/crossdomain.xml).

This can be accomplished using the virtualhost + url rewrite options CouchDB offers. This
has been described earlier by Nicolas (Orr) for blitz.io (neat app!):

He describes it as follows (I tried it, and it works beautifully):

<quote>

edit your domain.com<http://domain.com/> zone and add an A record for blitz.domain.com<http://blitz.domain.com/>
edit local.ini add a vhost
===
[vhosts]
blitz.domain.com:port = /blitz/_design/blitz/_rewrite
===
restart couchdb
create a blitz database
create a new document
===
{
  "_id": "_design/blitz",
  "rewrites": [
      {
          "from": "/mu-blitz-url",
          "to": "blitz.txt",
          "method": "GET",
          "query": {
          }
      }
  ]
}
===
save the document
create a blitz.txt file and put the content blitz told you put in it
upload blitz.txt as an attachment to the design document
goto blitz.domain.com:port/mu-blitz-url
you should get the content of the blitz.txt attachment

happy days :)

ok so now to test couchdb, i did want to hit the root of couchdb where it
reports the version however if you put "../../../" in the to of the rewrite
couchdb complains too many .. as a security issue, fair enough. so did 2x ..
and thus my design doc looks like this now
===
{
  "_id": "_design/blitz",
  "_rev": "7-0b8cf881f0dc8d26198703eb86e93eb1",
  "rewrites": [
      {
          "from": "/mu-blitz-url",
          "to": "blitz.txt",
          "method": "GET",
          "query": {
          }
      },
      {
          "from": "/",
          "to": "../../",
          "method": "GET",
          "query": {
          }
      }
  ]
}
===

<unquote>

Instead of blitz, of course, you need to figure out a hostname for the CouchDB database you
would like to access (e.g. flash.example.org<http://flash.example.org>)
make sure this hostname actually resolves to the machine you want to access (i.e. that runs
your CouchDB)

Then edit the virtual host part in your couchdb to reflect your choice (e.g.)
===
[vhosts]
flash.example.org:5984 = /flash/_design/flash/_rewrite
===
restart couchdb afterwards (i don't think this is even necessary if you add this entry through
Futon)


Use CouchApp (or any other way you like) to create a design document called _design/flash
that contains the crossdomain.xml file as attachment and a rewrite
statements much like mentioned above:

  "rewrites": [
      {
          "from": "/crossdomain.xml",
          "to": "crossdomain.xml",
          "method": "GET",
          "query": {
          }
      },
      {
          "from": "/:path",
          "to": "../../:path",
          "method": "GET",
          "query": {
          }
      }
]


curl 'http://flash.example.org/crossdomain.xml' should now provide you with the crossdomain.xml
you added as attachment.

The second rewrite points to the root of the database in question, allowing you to get documents
in the database:

http://yourserver:5984/flash/doc1 is now accessible through: http://flash.example.org:5984/doc1

This setup should allow your flash application to connect to the CouchDB without any problems.

Hope this helps,

Dennis

On 18 mrt 2011, at 23:03, edward de jong wrote:

I have the same problem; I am trying to access couch from the same machine as
myself, and actionscript (flash) is balking because it can't get the
crossdomain.xml file from root on that socket. I have tried copying
crossdomain.xml all over the place but no go. clearly it has to be inside couch,
but I have no idea how to stuff a crossdomain.xml file into couch; it isn't a
database, but just a text file that couch is being expected to spit up when
requested.... any help would be appreciate, every single person using
actionscript + couch will have the same problem!




Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message