Back

[SOLVED] Bad Gateway (502) - Nginx Proxy Manager with SSL certificate does not work

  • 0
  • General
THE-E
6 Aug, 2023, 20:54

I am trying to use Nginx Proxy Manager as Reverse Proxy. In Nginx Proxy Manager I have configured a Subdomain (https://baas.example.com) to the traefik container and its port (8000) as http://localhost:8000. I have created a SSL certificate in NPM for the subdomain pointing to appwrite/traefik.

I have tried to follow the visible instructions from Steven on Medium.com. Unfortunately it is for members only.

  • NPM is now added to the same network as appwrite-traefik container
  • I have added a docker-compose.override.yml with
TypeScript
version: '3'

services:
  traefik:
    image: traefik:2.7
    container_name: appwrite-traefik
    command:
      - --providers.file.directory=/storage/config
      - --providers.file.watch=true
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --providers.docker.constraints=Label(`traefik.constraint-label-stack`,`appwrite`)
      - --entrypoints.appwrite_web.address=:80
      - --entrypoints.appwrite_websecure.address=:443
      - --entrypoints.appwrite_web.forwardedHeaders.insecure
      - --entrypoints.appwrite_websecure.forwardedHeaders.insecure

I have restarted docker compose of appwrite and the setting for command are visible when using docker inspect.

When visiting https://baas.example.com the SSL certificate is visible but I get Bad Request 502 (openresty) as Error.

Appwrite Doctor has the following error:

TL;DR
The user solved the issue of receiving a Bad Gateway (502) error with Nginx Proxy Manager and SSL certificate not working. The solution was to ensure the Nginx Proxy Manager and Appwrite-Traefik containers were added to the same Docker network and to use the service name instead of an IP address. The user had set the environment variables `_APP_DOMAIN` and `_APP_DOMAIN_TARGET` to `baas.example.com`. They had configured Nginx Proxy Manager to use the traefik container and port (8000) using http://localhost:8000. The user had also created an SSL certificate in NPM
THE-E
6 Aug, 2023, 21:03

I have set the environment variables _APP_DOMAIN and _APP_DOMAIN_TARGET to baas.example.com.

Drake
6 Aug, 2023, 21:39

You can't use localhost because localhost refers to the current container (NPM and not Appwrite)

THE-E
6 Aug, 2023, 21:42

Do I need to use the IP address inside the (docker network shared with NPM) of the appwrite-traefik container?

Drake
6 Aug, 2023, 21:43

If they're in the same docker network, you can use the service name

THE-E
6 Aug, 2023, 21:47

That was the missing key. Thanks a lot, @Steven :appwriteheart2:

THE-E
6 Aug, 2023, 22:57

[SOLVED] Bad Gateway (502) - Nginx Proxy Manager with SSL certificate does not work

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more