Search code examples
vagrantejabberd

How to access eJabberd installed on a Vagrant box


I've installed eJabbered on my ubuntu box (Mac host) and for some reason can't access the admin panel (through localhost on my host machine). I'm trying to call the admin panel with localhost:5280/admin on my host machine. I've already tried with apache server to test if my port forwarding would be misconfigured and a lot of different options, that might cause a problem. Here are some configuration options from my ejabberd.yml file:

listen:
  - 
    port: 5222
    ip: "::"
    module: ejabberd_c2s
    certfile: "/etc/ejabberd/ejabberd.pem"
    starttls: true
    protocol_options:
      - "no_sslv3"
    max_stanza_size: 65536
    shaper: c2s_shaper
    access: c2s
    zlib: true
    resend_on_timeout: if_offline
  - 
    port: 5269
    ip: "::"
    module: ejabberd_s2s_in
  - 
    port: 5280
    ip: "::"
    module: ejabberd_http
    request_handlers:
      "/websocket": ejabberd_http_ws
    ##  "/pub/archive": mod_http_fileserver
    web_admin: true
    http_bind: true
    ## register: true
    ## captcha: true
    tls: true
    certfile: "/etc/ejabberd/ejabberd.pem"

hosts:
  - "localhost"

admin:
   user:
       - "": "localhost"

and my Vagrant file:

  config.vm.box = "ubuntu/xenial64"
  config.vm.hostname = "docker" #"web-dev"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 5222, host: 5222
  config.vm.network "forwarded_port", guest: 5269, host: 5269
  config.vm.network "forwarded_port", guest: 5280, host: 5280

I don't remember changing any other options that might be of use


Solution

  • Although it's just a quick fix I was able (with @gviews help) to figure out that my problem had nothing to do with a "Vagrantfile" (since I couldn't get it work even on my guest machine) but with a "tls" option (I set it to false) in my ejabberd configuration file. I still haven't established a secure connection and for testing purposes, just calling the page on my host, will suffice. After receiving:

    <?xml version='1.0'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
    <head>
      <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    </head>
    <body>
      <h1>Unauthorized</h1>
    </body>
    </html>
    

    response on my guest (by calling: curl localhost:5280/admin) I reloaded a vagrant box and after it I got it working on host either.

    PS. So the problem was the misconfigured ssl connection, and for me was the ejabberds log a great help (on ubuntu it's located under: /var/log/ejabberd)