添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
高大的洋葱  ·  WPF ...·  3 月前    · 
没有腹肌的麦片  ·  Error in: roslaunch ...·  7 月前    · 
没读研的油条  ·  该页面不存在·  1 年前    · 
volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - ./Traefik.yaml:/etc/traefik/traefik.yaml:ro - ./tls:/tls - ./acme.json:/acme.json labels: - "traefik.enable=true" # HTTP to HTTPS redirection - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)" - "traefik.http.routers.http-catchall.entrypoints=unsecure" - "traefik.http.routers.http-catchall.middlewares=redirect-to-https@docker" - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=secured" # Docker labels for enabling Traefik dashboard - "traefik.http.routers.traefik.rule=Host(`traefik.toto.xyz`)" - "traefik.http.routers.traefik.entrypoints=secure" - "traefik.http.routers.traefik.service=api@internal" - "traefik.http.routers.traefik.tls.certresolver=le" - "traefik.http.routers.traefik.middlewares=authTraefik" - "traefik.http.middlewares.authTraefik.basicauth.users=sdsdqdds" environment: - TZ=Europe/Paris networks: traefik: external: true

And my nginx docker-compose :slight_smile:

version: '3'
 services:
   perso:
     image: registry.gitlab.com/nginnnnx/sitecv
     container_name: ${NAME}
     restart: unless-stopped
     labels:
       - "traefik.enable=true"
       - "traefik.http.routers.${SERVICE}.rule=Host(`toto.xyz`) || Host(`www.toto.xyz`)"
       - "traefik.http.routers.${SERVICE}.entrypoints=secure"
       - "traefik.http.routers.${SERVICE}.tls.certresolver=le"
       - "traefik.http.services.${SERVICE}.loadbalancer.server.port=${PORT}"
     networks:
       - traefik
 networks:
   traefik:
     external: true

Can you help me ?

https is ok but http does not redirect to Https

This is the reference implementation I use for redirecting HTTP to HTTPS.

It is largely borrowed from the v1 to v2 migrations docs. It is easy to miss:

Below is taken from my own Production Reference Implementation (on Github)

  • simplecto/production-stack-template
  • # Redirect all HTTP to HTTPS permanently
    - traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)
    - traefik.http.routers.http_catchall.entrypoints=web
    - traefik.http.routers.http_catchall.middlewares=https_redirect
    - traefik.http.middlewares.https_redirect.redirectscheme.scheme=https
    - traefik.http.middlewares.https_redirect.redirectscheme.permanent=true
    

    I set :

           - "traefik.http.routers.http_catchall.rule= HostRegexp(`{any:.+}`)"
           - "traefik.http.routers.http_catchall.entrypoints=unsecure"
           - "traefik.http.routers.http_catchall.middlewares=https_redirect"
           - "traefik.http.middlewares.https_redirect.redirectscheme.scheme=secure"
           - "traefik.http.middlewares.https_redirect.redirectscheme.permanent=true"
    image1429×121 11.4 KB
    But still got
    image1043×408 12.7 KB
    

    I don't have that in my configs on the destination containers.

    This is what I have in my reference for django apps (for example):

    labels:
          - traefik.enable=true
          - traefik.http.routers.example.rule=Host(`example.com`,`www.example.com`)
          - traefik.http.routers.example.tls=true
          - traefik.http.routers.example.tls.certresolver=le
          - traefik.http.services.example.loadbalancer.server.port=8000
    
       labels:
          - "traefik.enable=true"
          - "traefik.http.routers.${SERVICE}.rule=Host(`toto.xyz`) || Host(`www.toto.xyz`)"
          - "traefik.http.routers.${SERVICE}.tls=true"
          - "traefik.http.routers.${SERVICE}.tls.certresolver=le"
          - "traefik.http.services.${SERVICE}.loadbalancer.server.port=80"
                  

    Let's go back to the firefox error message.

    Can you share the actual domains/addresses?

    Or, if not, would you mind doing this on the command line?

    curl -I http://example.com and show the output?

    Here is an example:

    deploy@prod:~/deployment/containers/traefik$ curl -I http://simplecto.com
    HTTP/1.1 308 Permanent Redirect
    Location: https://simplecto.com/
    Date: Mon, 24 Feb 2020 10:20:51 GMT
    Content-Length: 18
    Content-Type: text/plain; charset=utf-8
    
    11:19:40 › curl -I http://hjacquot.xyz
    HTTP/1.1 308 Permanent Redirect
    Location: secure://hjacquot.xyz/
    Date: Mon, 24 Feb 2020 10:27:50 GMT
    Content-Length: 18
    Content-Type: text/plain; charset=utf-8
    

    But why "secure://" ... :sweat_smile:

    so for some reason the system thinks I might be spam.

    This line:

           - "traefik.http.middlewares.https_redirect.redirectscheme.scheme=secure"
    

    should be

           - "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https"
                  

    It works ! Thanks again

    But i don't really understand why .... secure should be redirect to traefik.yaml declaration isn't it ?

    entryPoints:
      unsecure:
        address: ":80"
      secure:
        address: ":443"
                  

    https://docs.traefik.io/middlewares/redirectscheme/#redirectscheme

    That part of the docs references port numbers, not URL schemes. Given that Traefik can route TCP, that means there could be multiple schemes? (I'm kinda guessing here) I don't have experience with that however.

    Glad it worked out in the end. :slight_smile: