You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用FrankenPHP升级Laravel时Traefik+HTTPS环境出现500错误

问题:Laravel+FrankenPHP在Traefik HTTPS配置下返回500无日志,HTTP正常

我尝试用FrankenPHP提升现有Laravel应用的性能,预发布环境部署时出现问题,于是在本地搭建了Nomad+Traefik的复现环境。现在通过HTTPS加载应用时会返回500错误,但没有任何日志输出,换成HTTP配置则能正常运行。

composer.yml

networks:
  web:
    external: true

services:
  traefik:
    image: traefik:v2.4
    container_name: traefik
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    networks:
      - web
    ports:
      - 80:80
      - 8080:8080
      - 443:443
    volumes:
      - ./docker/traefik/static.yml:/etc/traefik/traefik.yml:ro
      - ./docker/traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro
      - ./ssl:/var/traefik2/tls:ro
      - /var/run/docker.sock:/var/run/docker.sock
  api:
    build:
      target: api-debug
    container_name: api
    image: api
    environment:
      - "SERVER_NAME=:80"
    env_file:
      - ./.env.docker-compose
    volumes:
      - ./app:/opt/api/app
      - ./bootstrap:/opt/api/bootstrap
      - ./public:/opt/api/public
      - ./routes:/opt/api/routes
      - ./storage:/opt/api/storage
      - ./resources:/opt/api/resources
      - ./.env.docker-compose:/opt/api/.env
    links:
      - database
      - cache
    networks:
      - web
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.myproject.rule=Host(`myproject.localhost`)"
      - "traefik.docker.network=web"
      - "traefik.http.services.myproject.loadbalancer.passhostheader=true"
      - "traefik.http.services.myproject.loadbalancer.server.scheme=https"
      - "traefik.http.routers.myproject.tls=true"
      - "traefik.http.routers.myproject.priority=100"
  cache:
    container_name: cache
    image: memcached:alpine
    networks:
      - web
    ports:
      - "11211:11211"
  database:
    image: mysql:8.4
    container_name: database
    platform: linux/x86_64
    environment:
      - MYSQL_DATABASE=app
      - MYSQL_ROOT_PASSWORD=secret
    ports:
      - 13306:3306
    networks:
      - web
    healthcheck:
      test: "/usr/bin/mysql --user=root --password=secret --execute \"SHOW DATABASES;\""
      interval: 3s
      timeout: 1s
      retries: 5

static.yml

global:
  sendAnonymousUsage: false

api:
  dashboard: true
  insecure: true

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    watch: true
    exposedByDefault: false

  file:
    filename: /etc/traefik/dynamic.yml
    watch: true

log:
  level: INFO
  format: common

http:
  serversTransports:
    mytransport:
      certificates:
        - certFile: /var/traefik2/tls/local-cert.pem
          keyFile: /var/traefik2/tls/local-key.pem
      insecureSkipVerify: true

entryPoints:
  http:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: https
          scheme: https
  https:
    address: ":443"

dynamic.yml

http:
  routers:
    traefik:
      rule: "Host(`traefik.localhost`)"
      service: "api@internal"
      tls:
        domains:
          - main: "myproject.localhost"
            sans:
              - "*.myproject.localhost"

tls:
  certificates:
    - certFile: "/var/traefik2/tls/local-cert.pem"
      keyFile: "/var/traefik2/tls/local-key.pem"

内容的提问来源于stack exchange,提问作者Eman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 18:13:22