matrix-org / go-neb

Extensible matrix bot written in Go
Apache License 2.0
285 stars 91 forks source link

Missing port in address #362

Closed BentEngbers closed 2 years ago

BentEngbers commented 2 years ago

The problem

I am trying to configure my own go-neb instance to connect to my EMS server (https://ems.element.io/), but i get the following error.

(dev.MY_SERVER.com and MY_EMS.ems.host are used as placeholders.)

go-neb    | time="2021-10-12T13:24:55Z" level=info msg="Go-NEB ({BindAddress:4050 DatabaseType:sqlite3 DatabaseURL:/data/go-neb.db?_busy_timeout=5000 BaseURL:http://dev.MY_SERVER.com:9050 LogDir: ConfigFile:/go-neb-config.yaml})"
go-neb    | time="2021-10-12T13:24:55Z" level=info msg="Inserted 1 clients"
go-neb    | time="2021-10-12T13:24:55Z" level=info msg="Inserted 1 realms"
go-neb    | time="2021-10-12T13:24:55Z" level=info msg="Inserted 1 sessions"
go-neb    | time="2021-10-12T13:24:55Z" level=info msg="Created new client" auto_join_rooms=true device_id=MY_DEVICE_ID since=s187237_43_2_522_1427_1_448_63_1 sync=true user_id="@goneb:MY_EMS.ems.host"
go-neb    | time="2021-10-12T13:24:55Z" level=info msg="Inserted 1 services"
go-neb    | time="2021-10-12T13:24:55Z" level=fatal msg="listen tcp: address 4050: missing port in address"

I am using docker-compose to create a nginx proxy and a go-neb container, with a config file. The nginx proxy is used to for SSL. My "architecture" is as follows

https://dev.MY_SERVER.com:9050

nginx container with ssl certificates

proxy to `localhost:4050`

go-neb container with config file

I have checked that the nginx proxy is reachable.


Additional Information

Below is the Dockerfile for go-neb.

FROM matrixdotorg/go-neb
ENV CONFIG_FILE=/go-neb-config.yaml
ENV BASE_URL=https://dev.labelsyringe.com:9050
ENV BIND_ADDRESS=4050
EXPOSE ${BIND_ADDRESS}
COPY /go-neb-config.yaml /go-neb-config.yaml

Below is the go-neb-config.yaml file


# The list of clients which Go-NEB is aware of.
# Delete or modify this list as appropriate.
# See the docs for /configureClient for the full list of options:
# https://matrix-org.github.io/go-neb/pkg/github.com/matrix-org/go-neb/api/index.html#ClientConfig
clients:
  - UserID: "@goneb:MY_EMS.ems.host"
    AccessToken: "MY_EMS_TOKEN"
    DeviceID: "MY_DEVICE_ID"
    HomeserverURL: "https://MY_EMS.ems.host"
    Sync: true
    AutoJoinRooms: true
    DisplayName: "My Bot"

# The list of realms which Go-NEB is aware of.
# Delete or modify this list as appropriate.
# See the docs for /configureAuthRealm for the full list of options:
# https://matrix-org.github.io/go-neb/pkg/github.com/matrix-org/go-neb/api/index.html#ConfigureAuthRealmRequest
realms:
  - ID: "github_realm"
    Type: "github"
    Config: {} # No need for client ID or Secret as Go-NEB isn't generating OAuth URLs

# The list of *authenticated* sessions which Go-NEB is aware of.
# Delete or modify this list as appropriate.
# The full list of options are shown below: there is no single HTTP endpoint
# which maps to this section.
# https://matrix-org.github.io/go-neb/pkg/github.com/matrix-org/go-neb/api/index.html#Session
sessions:
  - SessionID: "your_github_session"
    RealmID: "github_realm"
    UserID: "@goneb:MY_EMS.ems.host"
    Config:
      # Populate these fields by generating a "Personal Access Token" on github.com
      AccessToken: "MY_ACCESS_TOKEN"
      Scopes: "admin:org_hook,admin:repo_hook,repo,user"

# The list of services which Go-NEB is aware of.
# Delete or modify this list as appropriate.
# See the docs for /configureService for the full list of options:
# https://matrix-org.github.io/go-neb/pkg/github.com/matrix-org/go-neb/api/index.html#ConfigureServiceRequest
services:
  - ID: "example echo"
    Type: "echo"
    UserID: "@goneb:MY_EMS.ems.host"
    Config:

Below is the nginx configuration file

http {
    upstream go-neb {
        server localhost:4050;
    }
    server {
        listen 9050 ssl http2;
        server_name dev.labelsyringe.com;
        ssl_certificate /etc/nginx/certs/MY_SERVER.crt;
        ssl_certificate_key /etc/nginx/certs/MY_SERVER.key;
        location / {
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_cache_bypass $http_upgrade;
            proxy_pass http://go-neb;
        }

    }
}

Below is the docker-compose.yml

version: "3"

services:
  go-neb:
    container_name: go-neb
    #restart: unless-stopped
    build: ./go-neb/
    volumes:
      - go-neb_data:/data
    ports:
      - 4050:4050
  nginx:
    build: ./nginx/
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 9050:9050
volumes:
  go-neb_data:
BentEngbers commented 2 years ago

I have resolved the issue, apparently I should have not put ENV BIND_ADDRESS=4050 in the dockerfile of go-neb.