nioc / xmpp-web

Lightweight web chat client for XMPP server
GNU Affero General Public License v3.0
142 stars 20 forks source link

Use domain.tld for both XMPP and website #115

Closed roughnecks closed 10 months ago

roughnecks commented 10 months ago

Hello,

I have my prosody server at woo...t.space and I have my website at the same domain

Is there a way for me to host the webchat, so that it doesn't collide with my website?

I can host at a subdomain, but then my login credential don't work, since it tries to connect to e.g. webchat.woo...t.space, which is not my xmpp server's virtualhost.

nioc commented 10 months ago

Hello, it is possible with configuration in local.js

Let's say you have webdomain for the web GUI and xmppdomain for XMPP domain:

var config = {
  name: 'XMPP web',
  transports: {
    websocket: 'wss://webdomain/xmpp-websocket',
  },
  hasGuestAccess: false,
  hasRegisteredAccess: true,
  anonymousHost: 'anon.xmppdomain',
  isTransportsUserAllowed: false,
  hasHttpAutoDiscovery: false,
  resource: 'Web XMPP',
  defaultDomain: 'xmppdomain',
  defaultMuc: 'conference.xmppdomain',
  isStylingDisabled: false,
  hasSendingEnterKey: false,
  connectTimeout: 5000,
  pinnedMucs: ['welcome@conference.xmppdomain'],
}

And in proxy conf in Apache (for your webdomain):

<VirtualHost *:8810>
        ServerName   webdomain
        ServerAlias  webdomain
        # (...)
        # websocket proxy
        <IfModule mod_proxy_wstunnel.c>
                <Location "/xmpp-websocket">
                        ProxyPass "ws://xmppdomain:5280/xmpp-websocket"
                </Location>
        </IfModule>
</VirtualHost>
roughnecks commented 10 months ago

Hi.

came up with this (using nginx) but I still have problems authenticating: https://paste.woodpeckersnest.space/?c7a8446104c74c16#D3sUYFgrpE4WL9AouWRR2SPdMYUMFGCwb3eJeXSNiR45

roughnecks commented 10 months ago

This error is repeating in console:

index-0eca49fe.js:15 XMPP error WebSocket ECONNERROR ws://localhost/xmpp-websocket
(anonymous) @ index-0eca49fe.js:15
Ye.emit @ index-0eca49fe.js:15
s.error @ index-0eca49fe.js:15
Ye.emit @ index-0eca49fe.js:15
s.error @ index-0eca49fe.js:15
error (async)
_attachSocket @ index-0eca49fe.js:15
connect @ index-0eca49fe.js:15
connect @ index-0eca49fe.js:15
connect @ index-0eca49fe.js:15
TS.t.connect @ index-0eca49fe.js:15
reconnect @ index-0eca49fe.js:15
(anonymous) @ index-0eca49fe.js:15
setTimeout (async)
scheduleReconnect @ index-0eca49fe.js:15
s.disconnect @ index-0eca49fe.js:15
Ye.emit @ index-0eca49fe.js:15
_status @ index-0eca49fe.js:15
s.close @ index-0eca49fe.js:15
Ye.emit @ index-0eca49fe.js:15
s.close @ index-0eca49fe.js:15
index-0eca

why does it say localhost?

nioc commented 10 months ago

Can you type window.config.transports.websocket in console please?

nioc commented 10 months ago

On XmppSocket.js, it create a XMPP object with the socket in service attribute. If no value is provided, the XmppClient.js use ws://localhost:5280/xmpp-websocket as default.

I'm betting on an error in your local.json file.

nioc commented 10 months ago

@roughnecks I think it works now 😉 image

roughnecks commented 10 months ago

window.config.transports.websocket

'ws://localhost/xmpp-websocket'

did you check my paste? Config is there

roughnecks commented 10 months ago

working now, not sure if this line was needed:

// eslint-disable-next-line no-unused-vars, no-var

nioc commented 10 months ago

Not useful in production, it is for avoid linter complaints.