Running ejabberd behind a reverse proxy
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:
<span style="color:#323232;">stream {
</span><span style="color:#323232;"> upstream xmppserver {
</span><span style="color:#323232;"> server 10.8.0.3:5223;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">
</span><span style="color:#323232;"> upstream turnserver {
</span><span style="color:#323232;"> server 10.8.0.3:3478;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">
</span><span style="color:#323232;"> map $ssl_preread_alpn_protocols $upstream {
</span><span style="color:#323232;"> "xmpp-client" xmppserver;
</span><span style="color:#323232;"> "stun.turn" turnserver;
</span><span style="color:#323232;"> "stun.nat-discovery" turnserver;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">
</span><span style="color:#323232;"> server {
</span><span style="color:#323232;"> listen 6969;
</span><span style="color:#323232;"> proxy_pass $upstream;
</span><span style="color:#323232;"> proxy_protocol on;
</span><span style="color:#323232;"> }
</span><span style="color:#323232;">}
</span>
And I have a DNS entry telling XMPP clients to contact my server at port 6969 (this was just for testing):
https://discuss.tchncs.de/pictrs/image/8566e425-c33e-40ad-b94b-2359653d05d3.png
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.
Add comment