Rcstack redirect HTTP to HTTPS

The current documentation does not point how to redirect the HTTP requests to the HTTPS one.

For those wondering how to redirect the HTTP entrypoint to the HTTPS one, the clue is provided within the config/traefik/dynamic/traefik_dynamic.yaml or .custom/traefik_custom/dynamic/traefik_dynamic.yaml files:

## This is mounted in /etc/traefik_dynamic dir

http:                                                                                                                                                       

  middlewares:
    ## Middleware for redirect to https
    ## compose label: - "traefik.http.routers.<ROUTER_NAME>.middlewares=https-redirect@file"
    https-redirect:
      redirectScheme:
        scheme: https
        # permanent: true

My steps were:

To redirect http to https, uncomment the traefik entrypoints labels in .custom folder docmpose overrides files.

Edit docker-compose-apps.override.yaml and search for # Enable http+https endpoints comment, uncomment specific label, and add the middlewares label.

For example, to enable ssl mode and redirect http to https for RhodeCode:

service:
    rhodecode:
        labels:
          # Enable http+https endpoints to serve SSL, select just 1 to disable the other
          - "traefik.http.routers.rhodecode.entrypoints=http,https"
          # Redirect http to https
          - "traefik.http.routers.rhodecode.middlewares=https-redirect@file"

I did not add this middlewares label for the other entrypoints.

1 Like

Thanks for posting this, @aji. We will double-check the documentation and extend it accordingly.

1 Like