ERR_SSL_WRONG_VERSION_NUMBER when running nextjs in docker cointainer with traefik

The app shows 500 Internal server error on client, the log looks like this:

Error: fetch failed
    at context.fetch (/app/apps/webapp/.next/standalone/node_modules/.pnpm/next@14.0.2_@babel+core@7.23.2_react-dom@18.2.0_react@18.2.0_sass@1.66.1/node_modules/next/dist/server/web/sandbox/context.js:272:38)
    at Object.middleware_middleware [as handler] (/app/apps/webapp/.next/standalone/apps/webapp/.next/server/src/middleware.js:2253:15)
    at /app/apps/webapp/.next/standalone/apps/webapp/.next/server/src/middleware.js:1426:23
    at AsyncLocalStorage.run (node:async_hooks:346:14)
    at Object.wrap (/app/apps/webapp/.next/standalone/apps/webapp/.next/server/src/middleware.js:1238:24)
    at adapter (/app/apps/webapp/.next/standalone/apps/webapp/.next/server/src/middleware.js:1413:53)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: [Error: D07B0FDCAAAA0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:354:
  ] {
    library: 'SSL routines',
    reason: 'wrong version number',
    code: 'ERR_SSL_WRONG_VERSION_NUMBER'
  }
}

The next app is built with option output: standalone; and run using node server.js command.
We use Next.js v13.

Start by removing keyType: EC256, curvePreferences and cipherSuites to see if it works without.

Unfortunately, the error still persists

You state you use Next13, but the error shows Next14.

Where is the error happening? On client or on server? Within Docker? Connecting to which service? Where is Traefik involved?

Set Traefik to log level debug (doc). If the TLS error happens with Traefik you will see it there.

My mistake, I meant next 14, cant edit the post now.

Next server responds with 500, when the app is opened in a browser, the initial fetch fails.

All traefik logs relevant to the next app: traefik - Pastebin.com

Check your browser developer tools network tab. See if you can load that target URL within the browser itself.