Docker-zulip container server Installation apache2 server

Published by

on

According to Zulip support, Zulip has to work with nginx.

However, in our situation, we want to avoid nginx and want to use apache2 instead.

The only we resolve this issue is first install docker-zulip container which is a docker image and configure it.

Then, we make docker-zulip container as a reverse server which can be run on apache2.

We still have nginx, but nginx is with the docker-container.

  1. Install docker-zulip container on server
  2. then configure docker-compose.yml file which is under /src/docker-zulip
    docker-compose.yml
    add following information to .yml file along with other information

     ...
     zulip:
        ports:
          - "8088:80" (doesn't have to be port 8088)
          - "8089:443" (doesn't have to be port 8089)
        environment:
          ...
          SETTING_EXTERNAL_HOST: "whatever.yourdomain.com"
          SETTING_ALLOWED_HOSTS: "['whatever.yourdomain.com', '127.0.0.1']"
          SETTING_USE_X_FORWARDED_HOST: "True"
    
    Outgoing email setting:
    
    # SETTING_EMAIL_HOST: "localhost" # e.g. smtp.example.com
    SETTING_EMAIL_HOST: "gateway.byu.edu" - this is our case
    SETTING_EMAIL_HOST_USER: ""
    SETTING_EMAIL_PORT: "25"
    # It seems that the email server needs to use ssl or tls and can't be used without it
    SETTING_EMAIL_USE_SSL: "False" - it seems to me that I have to set SSL to false. Otherwise it won't work.
    SETTING_EMAIL_USE_TLS: "False" - I also need to set TLS false. 
    ZULIP_AUTH_BACKENDS: "EmailAuthBackend" - this is the default. 
    
    Save log files outside of zulip docker container
    Add the following two lines under - "/opt/docker/zulip/zulip:/data:rw". 
    # you will be able to access all log files even after the container crashes. 
    
    - "/opt/docker/zulip/zuliplogs:/var/log/nginx"
    - "/opt/docker/zulip/zuliplogs2:/var/log/zulip"
    
     volumes:
    - "/opt/docker/zulip/zulip:/data:rw"
    - "/opt/docker/zulip/zuliplogs:/var/log/nginx"
    - "/opt/docker/zulip/zuliplogs2:/var/log/zulip"
    
    
  3. configure your zulip.conf file on apache2 server
    <VirtualHost *:80>
    ServerName zulip.example.com
    RewriteEngine On
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </VirtualHost><VirtualHost *:443>
    ServerName zulip.example.comRequestHeader set “X-Forwarded-Proto” expr=%{REQUEST_SCHEME}
    RequestHeader set “X-Forwarded-SSL” expr=%{HTTPS}RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*) ws://localhost:8080/$1 [P,L]  (match your port number with your .yml file)
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*) http://localhost:8080/$1 [P,L] (match your port number with your .yml file)<Location />
    Require all granted
    ProxyPass http://localhost:8080/ timeout=300 (match your port number with your .yml file)
    ProxyPassReverse http://localhost:8080/ (match your port number with your .yml file)
    ProxyPassReverseCookieDomain 127.0.0.1 zulip.example.com
    </Location>

    Since we are using our own SSL, so we use the following lines instead.

    SSLEngine on
    SSLProxyEngine on
    SSLCertificateFile /etc/ssl/certs/server-wildcard-odh.crt
    SSLCertificateKeyFile /etc/ssl/private/server-wildcard-odh.key
    SSLCACertificateFile /etc/ssl/certs/ca.crt

    </VirtualHost>

  4. Start docker-zulip
    Got to /src/docker-zulip to start docker-zulip container
    If you have previously configured docker-compose.yml file, you will need to delete your zulip container before you start your docker container.Docker compose commandsdoker-compose down (shutdown docker-zulip container)
    docker system prune  -a (delete docker-zulip container)
    It will ask you if you want to delete all
    docker system prune – -volume -a (or this one dash dash volume)
    docker-compose pull (start again docker-zulip container)
    docker-compose up (start or start again docker-zulip container)
    docker-compose up -d (run it on the background)

Notes:

docker-zulip container configuration official documentation

https://github.com/zulip/docker-zulip#running-a-zulip-server-with-docker-compose

Information about configuring docker-compose.yml

https://github.com/zulip/docker-zulip/wiki/Proxying-via-nginx-on-host-machine

Apache2 Configuration

https://github.com/qnxor/zulip/blob/master/docs/production/deployment.md#apache2-configuration