Peppermint-Lab / peppermint

An open source issue management & help desk solution. A zendesk/freshdesk alternative
https://peppermint.sh
Other
2.03k stars 219 forks source link

Cannot run under traefik #148

Closed loranger closed 1 year ago

loranger commented 1 year ago

Hi, I try to run peppermint using traefik as a reverse proxy, but failed. Can you help ?

Here is my setup

.env ``` APP_PROJECT=peppermint APP_DOMAIN=peppermint.docker POSTGRES_USER=peppermint POSTGRES_PASSWORD=1234 POSTGRES_DB=peppermint PORT=5000 DB_USERNAME=${POSTGRES_USER} DB_PASSWORD=${POSTGRES_PASSWORD} DB_HOST=${APP_PROJECT}-postgres BASE_URL="http://${APP_DOMAIN}" ```
docker-compose.yml ```yaml version: "3.1" services: postgres: container_name: ${APP_PROJECT}-postgres image: postgres:latest restart: always volumes: - ./db:/data/db env_file: - .env client: container_name: ${APP_PROJECT}-peppermint image: pepperlabs/peppermint:latest # ports: # - 5000:5000 restart: on-failure depends_on: - postgres env_file: - .env labels: - "traefik.http.routers.${APP_PROJECT}.rule=Host(`${APP_DOMAIN}`)" - "traefik.http.services.${APP_PROJECT}-service.loadbalancer.server.port=${PORT}" networks: default: name: web ```

and here is my output whenever I try to login

output.log ``` docker compose up [+] Building 0.0s (0/0) [+] Running 2/0 ✔ Container peppermint-postgres Created 0.0s ✔ Container peppermint-peppermint Created 0.0s Attaching to peppermint-peppermint, peppermint-postgres peppermint-postgres | peppermint-postgres | PostgreSQL Database directory appears to contain a database; Skipping initialization peppermint-postgres | peppermint-postgres | 2023-06-16 19:06:09.906 UTC [1] LOG: starting PostgreSQL 15.3 (Debian 15.3-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit peppermint-postgres | 2023-06-16 19:06:09.907 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 peppermint-postgres | 2023-06-16 19:06:09.907 UTC [1] LOG: listening on IPv6 address "::", port 5432 peppermint-postgres | 2023-06-16 19:06:09.909 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" peppermint-postgres | 2023-06-16 19:06:09.911 UTC [29] LOG: database system was shut down at 2023-06-16 19:06:03 UTC peppermint-postgres | 2023-06-16 19:06:09.913 UTC [1] LOG: database system is ready to accept connections peppermint-peppermint | yarn run v1.22.19 peppermint-peppermint | $ prisma migrate deploy peppermint-peppermint | Environment variables loaded from .env peppermint-peppermint | Prisma schema loaded from prisma/schema.prisma peppermint-peppermint | Datasource "db": PostgreSQL database "peppermint", schema "public" at "peppermint-postgres:5432" peppermint-peppermint | peppermint-peppermint | 3 migrations found in prisma/migrations peppermint-peppermint | peppermint-peppermint | peppermint-peppermint | No pending migrations to apply. peppermint-peppermint | Done in 2.56s. peppermint-peppermint | yarn run v1.22.19 peppermint-peppermint | $ prisma generate peppermint-peppermint | Environment variables loaded from .env peppermint-peppermint | Prisma schema loaded from prisma/schema.prisma peppermint-peppermint | peppermint-peppermint | ✔ Generated Prisma Client (3.7.0 | library) to ./node_modules/@prisma/client in 330ms peppermint-peppermint | You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client peppermint-peppermint | ``` peppermint-peppermint | import { PrismaClient } from '@prisma/client' peppermint-peppermint | const prisma = new PrismaClient() peppermint-peppermint | ``` peppermint-peppermint | peppermint-peppermint | warn Versions of prisma@3.14.0 and @prisma/client@3.7.0 don't match. peppermint-peppermint | This might lead to unexpected behavior. peppermint-peppermint | Please make sure they have the same version. peppermint-peppermint | ┌─────────────────────────────────────────────────────────┐ peppermint-peppermint | │ Update available 3.14.0 -> 4.15.0 │ peppermint-peppermint | │ │ peppermint-peppermint | │ This is a major update - please follow the guide at │ peppermint-peppermint | │ https://pris.ly/d/major-version-upgrade │ peppermint-peppermint | │ │ peppermint-peppermint | │ Run the following to update │ peppermint-peppermint | │ yarn add --dev prisma@latest │ peppermint-peppermint | │ yarn add @prisma/client@latest │ peppermint-peppermint | └─────────────────────────────────────────────────────────┘ peppermint-peppermint | Done in 13.21s. peppermint-peppermint | yarn run v1.22.19 peppermint-peppermint | $ prisma db seed peppermint-peppermint | Environment variables loaded from .env peppermint-peppermint | Running seed command `node prisma/seed.js` ... peppermint-peppermint | { peppermint-peppermint | admin: { peppermint-peppermint | id: 1, peppermint-peppermint | createdAt: 2023-06-16T18:49:51.534Z, peppermint-peppermint | updatedAt: 2023-06-16T18:49:51.536Z, peppermint-peppermint | name: 'admin', peppermint-peppermint | password: '$2b$10$BFmibvOW7FtY0soAAwujoO9y2tIyB7WEJ2HNq9O7zh9aeejMvRsKu', peppermint-peppermint | email: 'admin@admin.com', peppermint-peppermint | isAdmin: true peppermint-peppermint | }, peppermint-peppermint | internal: { peppermint-peppermint | id: 1, peppermint-peppermint | createdAt: 2023-06-16T18:49:51.608Z, peppermint-peppermint | updatedAt: 2023-06-16T18:49:51.608Z, peppermint-peppermint | name: 'internal', peppermint-peppermint | email: 'internal@admin.com', peppermint-peppermint | contactName: 'admin', peppermint-peppermint | number: '123456789', peppermint-peppermint | notes: null peppermint-peppermint | } peppermint-peppermint | } peppermint-peppermint | peppermint-peppermint | 🌱 The seed command has been executed. peppermint-peppermint | Done in 3.03s. peppermint-peppermint | yarn run v1.22.19 peppermint-peppermint | $ next start peppermint-peppermint | ready - started server on 0.0.0.0:5000, url: http://localhost:5000 peppermint-peppermint | info - Loaded env from /app/.env peppermint-peppermint | warn - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled peppermint-peppermint | [next-auth][error][CLIENT_FETCH_ERROR] peppermint-peppermint | https://next-auth.js.org/errors#client_fetch_error request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80 { peppermint-peppermint | error: { peppermint-peppermint | message: 'request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80', peppermint-peppermint | stack: 'FetchError: request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80\n' + peppermint-peppermint | ' at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1461:11)\n' + peppermint-peppermint | ' at ClientRequest.emit (events.js:400:28)\n' + peppermint-peppermint | ' at Socket.socketErrorListener (_http_client.js:475:9)\n' + peppermint-peppermint | ' at Socket.emit (events.js:400:28)\n' + peppermint-peppermint | ' at emitErrorNT (internal/streams/destroy.js:106:8)\n' + peppermint-peppermint | ' at emitErrorCloseNT (internal/streams/destroy.js:74:3)\n' + peppermint-peppermint | ' at processTicksAndRejections (internal/process/task_queues.js:82:21)', peppermint-peppermint | name: 'FetchError' peppermint-peppermint | }, peppermint-peppermint | path: 'csrf', peppermint-peppermint | header: { peppermint-peppermint | host: 'peppermint.docker', peppermint-peppermint | 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/116.0', peppermint-peppermint | accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', peppermint-peppermint | 'accept-encoding': 'gzip, deflate', peppermint-peppermint | 'accept-language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3', peppermint-peppermint | cookie: 'next-auth.csrf-token=65c30271ea4bcb94bed3a3d67ede23092377740772243ff26e94ffecddea6d4d%7C97abf304ddc9a83cc9e04b9ac526537ba1621f13badbfb2ace7d4eef9bf2b3a1; next-auth.callback-url=http%3A%2F%2Fpeppermint.docker%2F', peppermint-peppermint | dnt: '1', peppermint-peppermint | referer: 'http://peppermint.docker/', peppermint-peppermint | 'upgrade-insecure-requests': '1', peppermint-peppermint | 'x-forwarded-for': '172.19.0.1', peppermint-peppermint | 'x-forwarded-host': 'peppermint.docker', peppermint-peppermint | 'x-forwarded-port': '80', peppermint-peppermint | 'x-forwarded-proto': 'http', peppermint-peppermint | 'x-forwarded-server': 'b89cf4dc9b37', peppermint-peppermint | 'x-real-ip': '172.19.0.1' peppermint-peppermint | }, peppermint-peppermint | message: 'request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80' peppermint-peppermint | } peppermint-peppermint | undefined peppermint-peppermint | [next-auth][error][CLIENT_FETCH_ERROR] peppermint-peppermint | https://next-auth.js.org/errors#client_fetch_error request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80 { peppermint-peppermint | error: { peppermint-peppermint | message: 'request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80', peppermint-peppermint | stack: 'FetchError: request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80\n' + peppermint-peppermint | ' at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1461:11)\n' + peppermint-peppermint | ' at ClientRequest.emit (events.js:400:28)\n' + peppermint-peppermint | ' at Socket.socketErrorListener (_http_client.js:475:9)\n' + peppermint-peppermint | ' at Socket.emit (events.js:400:28)\n' + peppermint-peppermint | ' at emitErrorNT (internal/streams/destroy.js:106:8)\n' + peppermint-peppermint | ' at emitErrorCloseNT (internal/streams/destroy.js:74:3)\n' + peppermint-peppermint | ' at processTicksAndRejections (internal/process/task_queues.js:82:21)', peppermint-peppermint | name: 'FetchError' peppermint-peppermint | }, peppermint-peppermint | path: 'csrf', peppermint-peppermint | header: { peppermint-peppermint | host: 'peppermint.docker', peppermint-peppermint | 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/116.0', peppermint-peppermint | accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', peppermint-peppermint | 'accept-encoding': 'gzip, deflate', peppermint-peppermint | 'accept-language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3', peppermint-peppermint | cookie: 'next-auth.csrf-token=65c30271ea4bcb94bed3a3d67ede23092377740772243ff26e94ffecddea6d4d%7C97abf304ddc9a83cc9e04b9ac526537ba1621f13badbfb2ace7d4eef9bf2b3a1; next-auth.callback-url=http%3A%2F%2Fpeppermint.docker%2F', peppermint-peppermint | dnt: '1', peppermint-peppermint | referer: 'http://peppermint.docker/auth/login?callbackUrl=http://peppermint.docker/&error=SessionRequired', peppermint-peppermint | 'upgrade-insecure-requests': '1', peppermint-peppermint | 'x-forwarded-for': '172.19.0.1', peppermint-peppermint | 'x-forwarded-host': 'peppermint.docker', peppermint-peppermint | 'x-forwarded-port': '80', peppermint-peppermint | 'x-forwarded-proto': 'http', peppermint-peppermint | 'x-forwarded-server': 'b89cf4dc9b37', peppermint-peppermint | 'x-real-ip': '172.19.0.1' peppermint-peppermint | }, peppermint-peppermint | message: 'request to http://peppermint.docker/api/auth/csrf failed, reason: connect ECONNREFUSED 127.0.0.1:80' peppermint-peppermint | } peppermint-peppermint | undefined ```

Did I miss something ? An environment variable maybe ?

potts99 commented 1 year ago

hmmm peppermint.docker should work as a base url

potts99 commented 1 year ago

https://docs.peppermint.sh/proxy maybe this might help but its an nginx example

loranger commented 1 year ago

Thanks for your reply

Actually it works, but I cannot pass the login form. As you can see on the log output, it seems there's an issue with next and the csrf.

Did you succeeded to make peppermint run with traefik?

potts99 commented 1 year ago

This will be resolved as i have departed from using next auth on the frontend :)