getkaiwa / kaiwa-server

Kaiwa XMPP Server
MIT License
113 stars 28 forks source link

Allow to change domain on which the Kaiwa server's websocket listens #14

Open stevenroose opened 8 years ago

stevenroose commented 8 years ago

It looks like kaiwa-server is listening only to a certain domain. This could easily be just localhost when a proxy relays all incoming traffic.

I use the docker nginx-proxy (once I get it to work, together with Let's Encrypt, I plan to put instructions in the README). However, it does not allow to split chat.example.org to kaiwa and chat.example.org/xmpp-websocket to kaiwa-server. Both are on port 443.

Thus I had to server kaiwa-server on a different subdomain, kaiwa.example.org, but it does not seem to listen to that domain. Or is something else wrong? I get a 404, not a 502 (which I got first due to malconfiguration).

This is my (edited) run command:

docker run -d \
  -p 5222:5222 -p 5269:5269 -p 5280:5280 -p 5281:5281 -p 3478:3478/udp \
  --name kaiwa-server \
  --link postgres:postgres \
  --link ldap:ldap \
  -e XMPP_DOMAIN=example.org \
  -e DB_NAME=kaiwa \
  -e DB_USER=kaiwa \
  -e DB_PWD=wassalon-postgresql \
  -e LDAP_HOST=example \
  -e LDAP_USER_BASE=ou=users,dc=example \
  -e LDAP_GROUP_BASE=ou=groups,dc=example \
  -e LDAP_DN=cn=admin,dc=example \
  -e LDAP_PWD=wassalon-ldap \
  -e LDAP_GROUP=exampleGroup \
  -e VIRTUAL_HOST=kaiwa.example.org \
  -e VIRTUAL_PORT=5280 \
  -e LETSENCRYPT_HOST=kaiwa.example.org \
  -e LETSENCRYPT_EMAIL=steven@example.org \
  sebu77/kaiwa-server
stevenroose commented 8 years ago

Indeed, my logs for kaiwa-server say

Jan 18 00:24:47 example.org:http    debug   Serving 'websocket' at https://example.org:5281/xmpp-websocket

Thus, not kaiwa.example.org. Please make this possible.

stevenroose commented 8 years ago

Solution:

Some modules expose their own URL in various ways. This URL is built from the protocol, http_host option and port used. If Prosody sits behind a proxy then this URL won't be the public one. You can tell prosody about this by setting the http_external_url option, like this: http_external_url = "http://www.example.com/"