Back

[SOLVED] NGINX before Appwrite and frontend app

  • 0
  • Self Hosted
  • Tools
AndrewIAm
13 Mar, 2023, 18:15

Repetive

TypeScript
appwrite-traefik  | 2023/03/13 18:15:01 traefik.go:80: command traefik error: error while building entryPoint appwrite_web: error preparing http server: parsing CIDR trusted IPs <nil>: invalid CIDR address: <IP of NPM container>```
TL;DR
User was experiencing a 502 error with NGINX before Appwrite and a frontend app. They made some updates to the vhost and now it works fine. The issue was that the frontend app was not in the NPM network. The user needed to ensure that the frontend app was in the network and make some configuration changes in the frontend app container. The logic is that NPM listens for connections to the domain name on the forward port and redirects to the HTTPS protocol to the appwrite-traefik container. The port should be 443. The user made the necessary changes and now Appwrite is accessible directly by port and by
Drake
13 Mar, 2023, 18:16

don't include the actual <>

AndrewIAm
13 Mar, 2023, 18:18

sorry, didn't get you

Drake
13 Mar, 2023, 18:18

like:

TypeScript
--entrypoints.appwrite_websecure.forwardedHeaders.trustedIPs=172.22.0.2
AndrewIAm
13 Mar, 2023, 18:19

ohh my!

AndrewIAm
13 Mar, 2023, 18:22

ok, now Appwrite accessible directly by port but not by domain name api.my-domain.name as configured in NPM

Drake
13 Mar, 2023, 18:29

What's the output of docker inspect npm_gateway now?

AndrewIAm
13 Mar, 2023, 19:27
TypeScript
    {
        "Name": "npm_gateway",
        "Id": "d372f2981bc8fce7b400512795375c21b28f0fe855ce14ca414ef6dd679e2f01",
        "Created": "2023-03-13T20:49:05.03979175+03:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.22.0.0/16",
                    "Gateway": "172.22.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "11fd0a365247e33088dd90ae9d5c785f78be2c3e5ef30577327474106bad5dc6": {
                "Name": "appwrite-traefik",
                "EndpointID": "c28f3c50156d192881c5d69390bc4f2675795fc13f2c74e6e444122bcf9adfe8",
                "MacAddress": "02:42:ac:16:00:03",
                "IPv4Address": "172.22.0.3/16",
                "IPv6Address": ""
            },
            "1d04dfa09df240f7f79caf3f2114b46650249f5f2176795b58533c4253cdf851": {
                "Name": "npm-app-1",
                "EndpointID": "5c93c995cb8b5789f174785fddc347c893835c35607de63b5c4c44663e339329",
                "MacAddress": "02:42:ac:16:00:02",
                "IPv4Address": "172.22.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "gateway",
            "com.docker.compose.project": "npm",
            "com.docker.compose.version": "2.16.0"
        }
    }
]```
Drake
13 Mar, 2023, 19:41

good. appwrite is in the NPM network. what did you do in NPM for the vhost?

AndrewIAm
13 Mar, 2023, 19:45

Did you mean Proxy host settings?

AndrewIAm
13 Mar, 2023, 19:49

If so this is my settings and SSL cert created as well

Drake
13 Mar, 2023, 20:09

the port should be 443

AndrewIAm
14 Mar, 2023, 05:51

So the logic is: NPM listen connection to domain name on Forward Port, user opens domain name then NPM redirects him to the https-protocol, to appwrite-traefik container (since it in the same network), correct?

Drake
14 Mar, 2023, 14:03

Yep!

AndrewIAm
14 Mar, 2023, 17:16

So, Appwrite finally alive and running fine. Now I can't run FE using another httpd-server container. Trying to do it in the same way as Traefik I can access it directly by IP:PORT but no via domain name, got 502 error. And my domain name is my-domain.name similar to Appwrite's api.my-domain.name. Inspecting NPM network I realized that my front-end app not in the NPM network. Assume that I have to do some config in my frontend-app container?

Drake
14 Mar, 2023, 17:19

yes you need to make sure your front end app is in the network just like how you did with appwrite's traefik container

AndrewIAm
14 Mar, 2023, 17:22

So my new docker-compose is:

TypeScript
version: '3.9'
services:
  apache:
    image: httpd:latest
    container_name: fe-app
    ports:
      - '3300:80'
    volumes:
      - ./www:/usr/local/apache2/htdocs
networks:
  gateway:
    name: npm_gateway
    external: true
Drake
14 Mar, 2023, 17:26

again, you need to make sure your app is in the network. declaring a network at the bottom doesn't put it in the network

AndrewIAm
14 Mar, 2023, 17:45

Well, front-end app is in the NPM network now:

TypeScript
            "11fd0a365247e33088dd90ae9d5c785f78be2c3e5ef30577327474106bad5dc6": {
                "Name": "appwrite-traefik",
                "EndpointID": "4544b3d4e7f7a69ae29e89ddb19a0352cca5320e39d90322c5d9a53d36dc4f6a",
                "MacAddress": "02:42:ac:16:00:02",
                "IPv4Address": "172.22.0.2/16",
                "IPv6Address": ""
            },
            "1d04dfa09df240f7f79caf3f2114b46650249f5f2176795b58533c4253cdf851": {
                "Name": "npm-app-1",
                "EndpointID": "6226a0f36d7030649a0e801f7cd6e626ec3667fd5ec8ab9f49287e9e4621154f",
                "MacAddress": "02:42:ac:16:00:03",
                "IPv4Address": "172.22.0.3/16",
                "IPv6Address": ""
            },
            "cca43df53d10aeff8893d163be674f8a5fed77f30cc84451246778b9c5bb735f": {
                "Name": "fe-app",
                "EndpointID": "b3fd4cb0d3c30daf2e69272848621f55de39d68e3292e45bad100cc1031596e4",
                "MacAddress": "02:42:ac:16:00:04",
                "IPv4Address": "172.22.0.4/16",
                "IPv6Address": ""
            }
        },

But I can't access my FE app via domain name

Camo
14 Mar, 2023, 17:55

why are you doing all this fuss ? you just neded to forward it to a port or container name in nginx proxy manager?

Camo
14 Mar, 2023, 17:56

when installing appwrite just chose different port than 80, and that's that, no ?

Camo
14 Mar, 2023, 17:56

i got a setup just like that at my home lab, running on 88 with np.

Drake
14 Mar, 2023, 17:57

what error are you getting? and what did you do for your vhost?

AndrewIAm
14 Mar, 2023, 18:04

It was 502 error, but after some updates in the vhost it works fine now. Thank you very much!

AndrewIAm
14 Mar, 2023, 18:05

[SOLVED] NGINX before Appwrite and frontend app

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