diff --git a/tandoor_recipes/rootfs/etc/nginx/servers/ingress.conf b/tandoor_recipes/rootfs/etc/nginx/servers/ingress.conf index 97a8b9429..8cc95dfd8 100644 --- a/tandoor_recipes/rootfs/etc/nginx/servers/ingress.conf +++ b/tandoor_recipes/rootfs/etc/nginx/servers/ingress.conf @@ -23,6 +23,31 @@ location /switch-space/ { absolute_redirect off; sub_filter_once off; sub_filter_types *; + # avoid mixed content + # Ensure work with both http and https (code by @met67) + if ($http_referer ~* "^(http[s]?)://([^:]+):(\d*)(/.*)$") { + set $x_scheme $1; + set $x_host $2; + set $x_port ":$3"; + } + # Ensure works if standard port (code by @met67) + if ($http_referer ~* "^(http[s]?)://([^:]+)(/.*)$") { + set $x_scheme $1; + set $x_host $2; + set $x_port ""; + } + proxy_set_header X-Scheme $x_scheme; + proxy_set_header X-Host $x_host; + proxy_set_header X-Port $x_port; + proxy_set_header X-Forwarded-Proto $x_scheme; + + proxy_set_header Host $x_host$x_port; # Required for addresses without ports + + # Correct url without port when using https + sub_filter_once off; + sub_filter_types *; + sub_filter https://$x_host/ https://$x_host$x_port/; + sub_filter http://$x_host/ http://$x_host$x_port/; sub_filter "/static" "%%ingress_entry%%/static"; sub_filter "/media" "%%ingress_entry%%/media"; @@ -75,6 +100,7 @@ location /switch-space/ { # Rewrite url sub_filter "/static" "%%ingress_entry%%/static"; sub_filter "/media" "%%ingress_entry%%/media"; + sub_filter "http://127.0.0.1:8080/" "/"; } location /media/ {