Wednesday, June 19, 2013

Installing ejabberd2 on CentOS and configure a virtual host on Apache2

1. Enable epel yum repository

Centos 5.x
sudo rpm -Uvh epel-release-5*.rpm

Centos 6.x
sudo rpm -Uvh epel-release-6*.rpm

2. Install ejabberd2
yum --enablerepo=epel install ejabberd

3. Start the ejabberd2 service
service ejabberd start

4. Edit the virtual hosts configuration file and add
  ProxyPass /http-bind
  ProxyPassReverse  /http-bind
  Header set Access-Control-Allow-Origin "YOUR_VIRTUAL_SERVER_HOSTNAME"

(please note that using "Header set Access-Control-Allow-Origin" enables Cross-origin resource sharing and using a wildcard as origin should not normally be used)

This is generally not appropriate. The only case where this is appropriate is when a page or api response is considered completely public content and it is intended to be accessible to browsable to everyone. Including any code on any site.

5. Test configuration
service httpd configtest

6. Reload apache configuration
service httpd reload

Since ejabberd comes with http-bind enabled out of the box
{5280, ejabberd_http, [
 %% [
 %%  {["pub", "archive"], mod_http_fileserver}
 %% ]},

you should now be able to access the XMPP over BOSH (XEP-0206) server in your browser looking somewhat like below.


No comments: