Trouble with Traefik's HTTPS redirection functionality

I am encountering an issue with my docker-compose setup using traefik 1.7 as a proxy for my Next.js website. Despite having successfully configured similar setups for other applications, I am unable to achieve http to https redirection on this particular website.

Below is an excerpt from my docker-compose.yml file:

version: '2'

services:
  proxy:
    image: traefik:1.7
    restart: always
    command: |-
      --logLevel=DEBUG
      --web
      --entrypoints='Name:http Address::80 Redirect.EntryPoint:https Redirect.Permanent:true'
      #--entrypoints='Name:http Address::80'
      --entrypoints='Name:https Address::443 TLS'
      --docker
      --acme
      --acme.entrypoint=https
      <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="90bdbdf1f3fdf5bef5fdf1f9fcade4f5e3e4d0fdf1f9fcbef3fffd">[email protected]</a>
      --acme.storage=/etc/traefik/acme.json
      --acme.ondemand=false
      --acme.onhostrule=true
      --acme.httpChallenge.entryPoint=http
    networks:
      - default
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik:/etc/traefik/
  website-preprod:
    image: registry/taggedimage
    restart: always
    labels:
      - "traefik.backend=my-website"
      - "traefik.frontend.rule=Host:domainname.com"
      - "traefik.docker.network=root_default"
      - "traefik.frontend.entryPoints=http,https"
      - "traefik.port=3000"
    environment:
      - HTTPS_CERT=server/certificates/dev.crt
      - HTTPS_KEY=server/certificates/dev.key
      - HTTP2=false
      - API_ENDPOINT=https://api.domainname.com/api
      - HTTPS=true
    depends_on:
      - proxy
    networks:
      - default
      - inner
networks:
  inner:
    driver: bridge
    internal: true

Although the HTTPS connection works fine, the redirection from http to https is not functioning as expected. Traefik logs show no errors, but the redirection itself does not occur.

Answer №1

It seems that the problem stemmed from the comment

#--entrypoints='Name:http Address::80'
. This line was causing a disruption in the redirection due to the way docker-compose translates to a command line.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble retrieving information from hash fetch fragment following authentication redirection in Angular 4

Once the authorization process is complete, the browser will be redirected to the following URL: &token_type=bearer&state=XYZ&expires_in=3599 However, just before I can retrieve the details, everything seems to disappear and the browser' ...

Angular2/4 preflight request encountered an invalid response which resulted in a redirect

In my project, I am utilizing angular4 for the frontend and a spring boot application for the backend. The communication between the frontend and BFF (backend for frontend) is done via RESTful requests. When the frontend sends a POST request to the backen ...

Navigate directly to the dashboard page in Angular 5 using RxJS without needing to load the main page first

Utilizing Firebase as the API in my application for authentication, database management, and storage. Implemented a main page (localhost:4200) that loads when the user is not logged in, and a dashboard (localhost:4200/dashboard) for authenticated users. ...