Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer

Appwrite was designed to be flexible and customizable, and that was one of the main reasons we designed it using the Microservices architecture. Thanks to this design, it’s very easy to adjust and deploy Appwrite on any existing architecture, especiall…


This content originally appeared on DEV Community and was authored by Damodar Lohani

Appwrite was designed to be flexible and customizable, and that was one of the main reasons we designed it using the Microservices architecture. Thanks to this design, it's very easy to adjust and deploy Appwrite on any existing architecture, especially container-based architectures.

When deploying Appwrite in your own architecture, you might already have your own load balancer or proxy server for handling routing between different services. If this is your case, you might not need to use the Appwrite built-in Traefik load balancer. This post will demonstrate how you can easily replace the Appwrite load balancer with an Nginx proxy. Although we use Nginx for this example, the same can be applied to any proxy or load balancer that your heart desires.

First, in the docker-compose.yml, comment out the traefik service. Now we will add nginx service to replace traefik and act as the entry point for Appwrite stack.

Below the traefik service, add the following.

nginx:
    image: nginx
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./config:/etc/nginx
      - appwrite-certificates:/etc/ssl/private
    depends_on:
      - appwrite
    networks:
      - gateway
      - appwrite

Here, we have added ./config volume. It contains the nginx config. Create config/nginx.conf file and add the following code.

events {
    worker_connections 1024;
}

http {
    server {
        listen 80;
        listen 443;

        # config for setting up and handling Appwrite SSL

        # ssl_certificate           /etc/ssl/private/YOUR_DOMAIN/cert.crt;
        # ssl_certificate_key       /etc/ssl/private/YOUR_DOMAIN/cert.key;
        # ssl on;
        # ssl_session_cache  builtin:1000  shared:SSL:10m;
        # ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        # ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        # ssl_prefer_server_ciphers on;

        server_name appwrite;

        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Port $server_port;
            proxy_pass http://appwrite;
        }
    }
}

Unlike the default Traefik instance that comes with Appwrite, the Nginx container doesn't handle SSL certificates automatically. For having valid SSL connections, you'll need to configure your own certificates or integrate with tools like Letsencrypt.

References


This content originally appeared on DEV Community and was authored by Damodar Lohani


Print Share Comment Cite Upload Translate Updates
APA

Damodar Lohani | Sciencx (2021-06-17T09:39:31+00:00) Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer. Retrieved from https://www.scien.cx/2021/06/17/learn-how-to-run-appwrite-with-your-own-custom-proxy-or-load-balancer/

MLA
" » Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer." Damodar Lohani | Sciencx - Thursday June 17, 2021, https://www.scien.cx/2021/06/17/learn-how-to-run-appwrite-with-your-own-custom-proxy-or-load-balancer/
HARVARD
Damodar Lohani | Sciencx Thursday June 17, 2021 » Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer., viewed ,<https://www.scien.cx/2021/06/17/learn-how-to-run-appwrite-with-your-own-custom-proxy-or-load-balancer/>
VANCOUVER
Damodar Lohani | Sciencx - » Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/17/learn-how-to-run-appwrite-with-your-own-custom-proxy-or-load-balancer/
CHICAGO
" » Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer." Damodar Lohani | Sciencx - Accessed . https://www.scien.cx/2021/06/17/learn-how-to-run-appwrite-with-your-own-custom-proxy-or-load-balancer/
IEEE
" » Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer." Damodar Lohani | Sciencx [Online]. Available: https://www.scien.cx/2021/06/17/learn-how-to-run-appwrite-with-your-own-custom-proxy-or-load-balancer/. [Accessed: ]
rf:citation
» Learn How to Run Appwrite With Your Own Custom Proxy or Load Balancer | Damodar Lohani | Sciencx | https://www.scien.cx/2021/06/17/learn-how-to-run-appwrite-with-your-own-custom-proxy-or-load-balancer/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.