Hi all,
As the title suggests, I’m trying to run an ejabberd (xmpp) server behind an nginx reverse proxy. The reason is, I want to be able to run the server on my raspberry pi at home, but have people connect to it through my VPS, which is running nginx. This would be nice because I don’t need a static ip and I don’t have to leak my ip address.
I have looked this up, but have not found an answer that works exactly for my use case.
My current nginx configuration looks like this:
stream {
upstream xmppserver {
server 10.8.0.3:5223;
}
upstream turnserver {
server 10.8.0.3:3478;
}
map $ssl_preread_alpn_protocols $upstream {
"xmpp-client" xmppserver;
"stun.turn" turnserver;
"stun.nat-discovery" turnserver;
}
server {
listen 6969;
proxy_pass $upstream;
proxy_protocol on;
}
}
And I have a DNS entry telling XMPP clients to contact my server at port 6969 (this was just for testing):
I would also need to figure out how to supply ejabberd with the correct certificates for the domain. Since it’s running on a different computer than the reverse proxy, would I have to somehow copy the certificate over every time it has to be renewed?
Thank you for your help.
I guess this is based on this guide? https://wiki.xmpp.org/web/Tech_pages/XEP-0368
But since you don’t actually need to multi-plex HTTP with XMPP, why not just configure port forwarding like you would do in a local network (assuming your VPS is connected to your Rasberry via a Wireguard VPN or similar)?
For the certs you can request them again from your Rasberry easily if you use the DNS-01 method. That also allows you to get wildcard certs, which are very useful with the multiple subdomains you usually have for a XMPP service.