Backend running http external login does not accept that

1. Caddy version (caddy version):

caddy:2.4.6

2. How I run Caddy:

with docker-compose

a. System environment:

Docker-compose
version: ‘3.5’

b. Command:

docker-compose up

c. Service/unit/compose file:

version: '3.5'

volumes:
  mysql-data:
  caddy_data:
  caddy_config:
  #saving keys from client to avoid dataprotection presistance warning
  client_keys:
  certs:

networks:
  web:
    name: web

services:
  database:
    .......

  API:
    ......


  client:
    build:
      context: .
      dockerfile: Client/Client.Dockerfile
    container_name: client
    restart: unless-stopped
    env_file: 
      - .env
    # expose:
    #   - 80
    #   - 443
    environment:
      # VIRTUAL_HOST: "${HOST}"
      # LETSENCRYPT_HOST: "${HOST}"
      # LETSENCRYPT_EMAIL: "${EMAIL}"
      ASPNETCORE_ENVIRONMENT: Production
      WORDPRESS_DB_HOST: database:3306
      WORDPRESS_DB_USER: $MYSQL_USER
      WORDPRESS_DB_PASSWORD: $MYSQL_PASSWORD
      WORDPRESS_DB_NAME: UiA_DB
      # ASPNETCORE_URLS: https://+:443;http://+:80
      # ASPNETCORE_Kestrel__Certificates__Default__Path: /certs/iotuia.ddns.net.crt
      # ASPNETCORE_Kestrel__Certificates__Default__KeyPath: /certs/iotuia.ddns.net.key
    volumes:
      - client_keys:/root/.aspnet/DataProtection-Keys
      - certs:/certs
    depends_on: 
      - database
      - api
    networks:
      - web

  
  caddy:
    image: caddy:2.4.6
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
      - certs:/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/iotuia.ddns.net
    environment:
      - LOG_FILE=/data/access.log
    # depends_on: 
      # - client
      # - api
    networks:
      - web

d. My complete Caddyfile or JSON config:

iotuia.ddns.net {
	reverse_proxy client:80
}

3. The problem I’m having:

My website running on Client uses a third-party login, but when I’m sent to that site for login, there seems to be missing something from my header file, because the return URL that my client provides is HTTP instead of HTTPS.

When I run this in development locally with port 8001 as HTTPS, it all works as it should, but when I use caddy, it does not work.
I’ve been trying to solve this problem for a long time, but I cannot find anyone with the problem I’m having which is weird. I have been looking at the documentation on Caddy, but I cannot make heads or tails of anything since there are a lot of different parameters to use, but no clear examples of code on how they should look, only pseudo code.

look at the diagram to see how the page should work.

4. Error messages and/or full log output:

5. What I already tried:

If i run the docker-compose file, dotnet will only be running with HTTP, but my thinking is that it should not matter as long as it is behind Caddy, but when dotnet redirects me to Feide for login, it seems that something is happening so that the redirect is only HTTP like shown in 4.

I’ve tried to use the tls certificate from Caddy in my client as you can see in my docker-compose config file, which will allow dotnet to run with both HTTP and HTTPS but does not work either.

the Caddyfile I am using now is the only one that has worked and actually forwarded me into the Client.

6. Links to relevant resources:

edit: corrected docker-compose file and Caddyfile