< HTTP/1.1 308 Permanent Redirect

1. The problem I’m having:

I’ve faced something like that

2. Error messages and/or full log output:


curl -v --location http://localhost:8080/health

* Host localhost:8080 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET /health HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 308 Permanent Redirect
< Connection: close
< Location: https://localhost/health
< Server: Caddy
< Date: Wed, 18 Jun 2025 19:58:29 GMT
< Content-Length: 0
< 
* Closing connection
* Clear auth, redirects to port from 8080 to 443
* Issue another request to this URL: 'https://localhost/health'
* Host localhost:443 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:443...
* connect to ::1 port 443 from ::1 port 52945 failed: Connection refused
*   Trying 127.0.0.1:443...
* connect to 127.0.0.1 port 443 from 127.0.0.1 port 52946 failed: Connection refused
* Failed to connect to localhost port 443 after 0 ms: Couldn't connect to server
* Closing connection
curl: (7) Failed to connect to localhost port 443 after 0 ms: Couldn't connect to server

3. Caddy version:

FrankenPHP v1.1.0 PHP 8.3.4 Caddy v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

4. How I installed and ran Caddy:

{
    auto_https off
}

:80 {
    root * /app/public
    encode gzip

    php_fastcgi frankenphp

    rewrite /index.php{uri}
    rewrite * /index.php

    log {
        output stdout
        format console
        level DEBUG
    }
}

This is Caddyfile


COPY ./src /app

COPY ./Caddyfile /etc/frankenphp/Caddyfile

# Set working directory
WORKDIR /app

# Install required dependencies
RUN set -xe \
    && apt-get update && apt-get install -y \
        git \
        unzip \
        curl \
        libpng-dev \
        libzip-dev \
        libonig-dev \
        libxml2-dev \
        zlib1g-dev \
        libcurl4-openssl-dev \
        libpq-dev \
        libsqlite3-dev \
        default-mysql-client \
    && docker-php-ext-install \
        pdo \
        pdo_mysql \
        mbstring \
        zip \
        bcmath \
        opcache \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Configure Composer and install dependencies
RUN composer config --global --auth github-oauth.github.com ghp_xxxxxxx
RUN composer install -v --ignore-platform-reqs

# Create log directory for PHP-FPM
RUN mkdir -p /var/log/php-fpm && ln -sf /dev/stderr /var/log/php-fpm/error.log

# Expose port 80
EXPOSE 80

this is dockerfile-php


services:
  php:
    build:
      context: .
      dockerfile: dockerfile-php
    container_name: realtime_laravel_app
    ports:
      - "8080:80"
    environment:
      FRANKENPHP_CONFIG: /etc/frankenphp/Caddyfile
      DB_CONNECTION: mysql
      DB_HOST: db
      DB_PORT: 3307
      DB_DATABASE: realtime
      DB_USERNAME: realtime
      DB_PASSWORD: realtime
      REDIS_HOST: redis
      REDIS_PORT: 6379
      CACHE_DRIVER: redis
      QUEUE_CONNECTION: redis
    depends_on:
      - db
      - redis
    volumes:
      - ./src:/app

  db:
    image: mysql:8.4
    container_name: realtime_db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: realtime
      MYSQL_USER: realtime
      MYSQL_PASSWORD: realtime
    ports:
      - "3307:3306"
    volumes:
      - dbdata:/var/lib/mysql

  redis:
    image: redis:6.2.1-buster
    container_name: realtime_redis
    ports:
      - "6379:6379"
    restart: unless-stopped

volumes:
  dbdata

This is docker-compose.yml.

How can i approach to fix it?