Quantcast
Viewing all articles
Browse latest Browse all 1600

Allow both http and https with Traefik on Docker

I am using Traefik in my VPS to route the traffic to my websites, after hours of messing around with it I finally managed to get it working with https using Le's Encrypt.

Now, one thing that I need to do is be able to also access my website via plain http as this is a hobby project for older browsers and the only reason I added tls is because Firefox doesn't like my website without it.

The problem is that, with my current configuration, I can access my website via https normally but when I try it with plain http I get a 404 error.

Here's what my config on docker-compose looks like:

version: "3"services:  traefik:    image: "traefik:v2.5"    container_name: "traefik"    command:      #- "--log.level=DEBUG"      - "--api.insecure=true"      - "--providers.docker=true"      - "--providers.docker.exposedbydefault=false"      - "--entrypoints.web.address=:80"      - "--entrypoints.websecure.address=:443"      - "--certificatesresolvers.teeresolver.acme.tlschallenge=true"      - "--certificatesresolvers.teeresolver.acme.email=me@gmail.com"      - "--certificatesresolvers.teeresolver.acme.storage=/letsencrypt/acme.json"    ports:      - "443:443"      - "80:80"      - "8080:8080"    volumes:      - "./letsencrypt:/letsencrypt"      - "/var/run/docker.sock:/var/run/docker.sock:ro"    networks:      - mywebsite  # [...]  mywebsite:    image: my-web-site/site    build:      context: ~/mywebsite-runner/_work/my-web-site-php/my-web-site-php      dockerfile: Dockerfile    volumes:      - ./tee-downloads:/var/www/build/downloads      - ./tee-contents:/var/www/build/contents    ports:      - "0.0.0.0:8001:80"    labels:      - "traefik.enable=true"      - "traefik.http.routers.themywebsite.rule=Host(`mywebsite.com`, `www.mywebsite.com`)"      - "traefik.http.routers.themywebsite.entrypoints=websecure,web"      - "traefik.http.routers.themywebsite.tls.certresolver=teeresolver"    networks:      - mywebsitenetworks:  mywebsite:

I have been searching for a solution for hours but the only things I can find on google are configs to redirect http to https, which I can't do.

Does anyone know how to do that?

Thanks in advance for the help.


Viewing all articles
Browse latest Browse all 1600

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>