C
Coder.com2y ago
max

Issues with external Postgres DB

When I run Coder with the internal DB, it works flawlessly. As soon as I try with an external Postgres database, I get 401 errors such as "the API key is invalid" and 404 errors such as "Resource not found or you do not have access to this resource". Template creation fails with logs: decode body: invalid character '<' looking for beginning of value.
version: "3.8"

networks:
t2_external:
external: true

services:
coder:
image: ghcr.io/coder/coder:latest

command: chmod 666 /var/run/docker.sock

networks:
- t2_external

volumes:
- /var/run/docker.sock:/var/run/docker.sock

environment:
CODER_PG_CONNECTION_URL: "postgresql://coder-user:CoderTempPW!@10.34.12.1:5432/coder?sslmode=disable"
CODER_ADDRESS: "0.0.0.0:7080"
CODER_ACCESS_URL: "https://coder.mydomain.com"
CODER_OAUTH2_GITHUB_ALLOW_SIGNUPS: "true"
CODER_OAUTH2_GITHUB_ALLOWED_ORGS: "my-org"
CODER_OAUTH2_GITHUB_CLIENT_ID: "12345"
CODER_OAUTH2_GITHUB_CLIENT_SECRET: "abcde"

deploy:
labels:
- traefik.enable=true
- traefik.docker.network=t2_external
- traefik.http.routers.coder-rtr.entrypoints=https
- traefik.http.routers.coder-rtr.rule=Host(`coder.mydomain.com`)
- traefik.http.services.coder.loadbalancer.server.port=7080
version: "3.8"

networks:
t2_external:
external: true

services:
coder:
image: ghcr.io/coder/coder:latest

command: chmod 666 /var/run/docker.sock

networks:
- t2_external

volumes:
- /var/run/docker.sock:/var/run/docker.sock

environment:
CODER_PG_CONNECTION_URL: "postgresql://coder-user:CoderTempPW!@10.34.12.1:5432/coder?sslmode=disable"
CODER_ADDRESS: "0.0.0.0:7080"
CODER_ACCESS_URL: "https://coder.mydomain.com"
CODER_OAUTH2_GITHUB_ALLOW_SIGNUPS: "true"
CODER_OAUTH2_GITHUB_ALLOWED_ORGS: "my-org"
CODER_OAUTH2_GITHUB_CLIENT_ID: "12345"
CODER_OAUTH2_GITHUB_CLIENT_SECRET: "abcde"

deploy:
labels:
- traefik.enable=true
- traefik.docker.network=t2_external
- traefik.http.routers.coder-rtr.entrypoints=https
- traefik.http.routers.coder-rtr.rule=Host(`coder.mydomain.com`)
- traefik.http.services.coder.loadbalancer.server.port=7080
The only difference between a working and non working implementation is the CODER_PG_CONNECTION_URL line.
2 Replies
max
max2y ago
When trying to create a template:
2022-09-15 18:03:35.681 [WARN] (coderd) <./coderd/httpmw/logger.go:55> Logger.func1.1 GET {"host": "coder.mydomain.com", "path": "/api/v2/organizations/07e7005a-3baf-42fa-ab01-901ec794a97b/templates/test-docker", "proto": "HTTP/1.1", "remote_addr": "10.0.1.73:43406", "took": "9.517499ms", "status_code": 404, "latency_ms": 9, "response_body": "{\"message\":\"Resource not found or you do not have access to this resource\"}\n", "request_id": "dcf58420-6dbb-4b52-8955-0967d583d1cb"}
2022-09-15 18:03:35.681 [WARN] (coderd) <./coderd/httpmw/logger.go:55> Logger.func1.1 GET {"host": "coder.mydomain.com", "path": "/api/v2/organizations/07e7005a-3baf-42fa-ab01-901ec794a97b/templates/test-docker", "proto": "HTTP/1.1", "remote_addr": "10.0.1.73:43406", "took": "9.517499ms", "status_code": 404, "latency_ms": 9, "response_body": "{\"message\":\"Resource not found or you do not have access to this resource\"}\n", "request_id": "dcf58420-6dbb-4b52-8955-0967d583d1cb"}
Ok so this is actually solved. I was going through a L2 switch instead of a L3 and somehow even though pfSense is configured the right way, something was blocking 'some' packets. Routed on the L3 switch, it's flawless. Weird!
kyle
kyle2y ago
Happy you got it solved! I was confused, because we don't have "request_id" in any of our payloads!
Want results from more Discord servers?
Add your server