I installed a fresh Ubuntu18 server with Nextcloud and Rocketchat installed through snap.

After enabling letsencrypt, Nextcloud listens on port 443 and Rocketchat on port 3000.

I would like both to listen on port 443 based on domain names without having to deal with their certificates. (https://rocketchat.example.com:443 and https://nextcloud.example.com:443).

When I searched, it appears that I should install apache or nginx and do a proxy server. But everything was dealing directly with the certificates, which I would like to avoid. Is it possible ?


This question gave me the hint on how to do and I came to the following config file for an apache reverse proxy:


LoadModule ssl_module modules/mod_ssl.so

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        ServerName nextcloud.example.com

        SSLProxyEngine On
        SSLProxyVerify none
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off
        SSLProxyCheckPeerExpire off

        SSLCertificateFile /var/snap/nextcloud/current/certs/live/fullchain.pem
        SSLCertificateKeyFile /var/snap/nextcloud/current/certs/live/privkey.pem

        Proxypass / https://localhost:44300/
        ProxypassReverse / https://localhost:44300/


<VirtualHost _default_:443>
        ServerName rocketchat.example.com

        SSLCertificateFile /etc/letsencrypt/live/chat.ljp.upmc.fr/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/chat.ljp.upmc.fr/privkey.pem

        <Location />
                Order allow,deny
                Allow from all

        RewriteEngine On
        RewriteCond %{HTTP:Upgrade} =websocket [NC]
        RewriteRule /(.*)           ws://localhost:3000/$1 [P,L]
        RewriteCond %{HTTP:Upgrade} !=websocket [NC]
        RewriteRule /(.*)           http://localhost:3000/$1 [P,L]

        ProxyPassReverse / http://localhost:3000/


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.