Hi there,
We are developing a flash application which will connect to a ejabberd server through http-bind on port 80.
The flash application requires to have a crossdomain.xml file served on http-bind's "parent URL", e.g.:
-- or --
I have *unsuccessfully* tried this second approach by applying these setting on my ejabberd.cfg file:
%% Listen section
%% ...
{80, ejabberd_http, [
http_poll,
web_admin,
{request_handlers, [{["http-bind","con"], mod_http_bind}]},
{request_handlers, [{["http-bind"], mod_http_fileserver}]}
]}
%% ...
and ...
%% Modules section
%% ...
{mod_http_bind,[]},
{mod_http_fileserver, [{docroot, "/opt/ejabberd-2.0.0/www"}]},
%% ...
/opt/ejabberd-2.0.0/www contents:
ls -lash /opt/ejabberd-2.0.0/www/
total 12K
4.0K drwxr-xr-x 2 root root 4.0K 2008-02-07 11:51 .
4.0K drwxr-xr-x 9 root root 4.0K 2008-02-07 10:36 ..
4.0K -rwxr-xr-x 1 root root 204 2008-02-07 10:58 crossdomain.xml
This approach works randomly, showing an HTTP 404 not found error accessing the http-bind connector (aka
NOTE: Both modules work if enabled alone (aka mod_http_bind & mod_http_fileserver) with that exact configuration.
Our ejabberd server: debian linux 4.0 with ejabberd-2.0.0-rc1 installed using this binary:
How could I serve http-bind and the crossdomain file simultaneously? Any thoughts?
Thank you so much!
Only one request_handlers, and put inside all the handlers
You were quite close to the solution, try this one :)
crossdomain.xml and http-bind from the same port 5280
Hi,
i was able to setup http-bind in port 5280 and jwchat client can work properly.
but when using xiff/BOSH client, flash complains that it cannot find the policy file from
my ejabber server domain.
my ejabberd server ishttp://jabber.foo.com:5280/http-bind
I setup my ejabberd.cfg as below.
{5280, ejabberd_http, [
http_poll,
http_bind,
web_admin,
{request_handlers, [
{["presence"], mod_webpresence},
{["web"], mod_http_fileserver}
]}
but i get the policy error on the client as follows.
Warning: Failed to load policy file fromhttp://jabber.foo.com:5280/crossdomain.xml http://jabber.foo.com:5280/http-bind/ by requestor from http://cybersnl.bar.com/assets/flash/fx_jabber.swf is denied due to lack of policy file permissions.
Error: Request for resource at
Since the docroot of the http file server is athttp://jabber.foo.com:5280/web as per the above config, howhttp://jabber.foo.com:5280/crossdomain.xml ?
is the flash client supposed to load the policy file from
i tried using "/" in the request handler instead of "web" to get around that. but no success.
has anybody got it to work yet?
i will appreciate any suggestions or tips. I will be thankful.
Patch available, but not confirmed yet to work
There is a patch proposed in the mailing list, but I didn't test it, and the person that posted it didn't mention if it works for him now. The patch for ejabberd 2.0.1 is in this email:[ejabberd] Flash jabber client : Howto serve cross-domain policy .
If you can try the patch, please tell here if it works correctly or not.
[ejabberd] Flash jabber client : Howto serve cross-domain policy
Patched/Compiled/Implemented.
With the patched version, returns stream:error - invalid namespace xmlns.
Unpatched version returns same error.
Perhaps patched section of code never get's executed.
I would suggest (for a number of reasons) putting the test for policy-file-request inside the stream error segment.
NOTE: MADE SOME CHANGES, now works. Advised author.
Yes, it works also for me :)
Unfortunately, I have no experience with Erlang at all... BTW, I managed to successfull patch the ejabberd_c2s_erl file (ejabberd 2.0.1_2)
Maybe, this is not OK in words of preformance... I don't know, sorry, but it works!
You should add following lines right after "Func: StateName/2" comment block (line 222)
---------------
wait_for_stream({xmlstreamstart, "policy-file-request", _Attrs}, StateData) ->
ejabberd_socket:reset_stream(StateData#state.socket),
send_text(StateData,
"<?xml version=\"1.0\"?>\n"
"<!DOCTYPE cross-domain-policy SYSTEM "
"\"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\n"
"<cross-domain-policy>\n"
" <allow-access-from domain=\"*\" to-ports=\"5222\"/>\n"
" <allow-access-from domain=\"*\" to-ports=\"5269\"/>\n" %% in case your ejabberd also configured to answer the legacy jabber port -5269
"</cross-domain-policy>\n\0"),
{stop, normal, StateData};
----------
I think, it's not a very good idea to allow all ports to flash clients... I'm afraid, some "bad guys" can write flash-client, that quickly requests thousands web-pages, for example... and put this client (with invisible or small layout) to popular web-site... and You can get something like DDOS attack (thousands connections from different IP's)
Regards,
If you are using the older
If you are using the older ejabberd 1.X you will need to change the reset_stream command.
Replace:
ejabberd_socket:reset_stream(StateData#state.socket)
with:
ejabberd_receiver:reset_stream(StateData#state.receiver)
Can you post the working patch?
Hey Mike,
Can you post the changes you made to get this patch working? Thanks!
policy-file-request on ejabberd_c2s port patch - SUCCESS
Just sent off an eMail to badlop to confirm patch relocation.
I patched and compiled the code referred to in badlop's post.
Didn't work.
I moved the code in the patch file to a different location in the code. It then worked.
I've sent an eMail to badlop advising him of the success on my server. It may be best for badlop to check, test and revise so that the relocation doesn't cause unforeseen problems on other's servers.
Works very nicely. Solves the immediate problem.
-=MD=-
why didn't you test it. Give
why didn't you test it. Give a solution to this issue.
You can check this patch
You can check this patch recently updated:Serve cross domain policy file for Flash
crossdomain.xml and ejabberd working with XIFF (no patching)
What we did was to make sure the virtual host name (set during installation or listed in the ejabberd.cfg) is exactly the same as the domain name serving the crossdomain.xml file. We did have issues with getting http-bind to serve the crossdomain.xml so we just installed Apache and used that instead. So:
Virtual host = xmpp.example.com (configured in ejabberd)http://xmpp.example.com (served by the Apache installation)
Web server URL =
crossdomain.xml was placed in the root of the Apache web server
Note: we used the standard configuration of ejabberd and made no modifications to the 5280 listeners. We didn't use the patch. We are using the windows version.
I hope this helps those still struggling to get this working. We are still trying to fine tune the configuration.