Skip to content

Commit

Permalink
http->https redirect (#298)
Browse files Browse the repository at this point in the history
* http->https redirect

* redirect only if tls enabled

* static fix
  • Loading branch information
PietroPasotti authored Mar 4, 2024
1 parent ad6db7b commit 41683ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/traefik.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,24 @@ def _update_static_configuration(self):
tcp_entrypoints = self._tcp_entrypoints
logger.debug(f"Statically configuring traefik with tcp entrypoints: {tcp_entrypoints}.")

web_config: Dict[str, Any] = {
"address": f":{self.port}",
}

if self._tls_enabled:
# enable http -> https redirect
web_config["http"] = (
{"redirections": {"entryPoint": {"to": "websecure", "scheme": "https"}}},
)

# TODO Disable static config with telemetry and check new version
raw_config = {
"log": {
"level": "DEBUG",
},
"entryPoints": {
"diagnostics": {"address": f":{_DIAGNOSTICS_PORT}"},
"web": {"address": f":{self.port}"},
"web": web_config,
"websecure": {"address": f":{self.tls_port}"},
**{
tcp_entrypoint_name: {"address": f":{port}"}
Expand Down

0 comments on commit 41683ed

Please sign in to comment.