diff --git a/smartgears/smartgears/templates/container.xml.j2 b/smartgears/smartgears/templates/container.xml.j2
index 74a863fc..2f0a5b04 100644
--- a/smartgears/smartgears/templates/container.xml.j2
+++ b/smartgears/smartgears/templates/container.xml.j2
@@ -3,10 +3,12 @@
{{ smartgears_hostname }}
{%if setup_nginx %}
{%if https_port is defined %}
+ {% if http_redirect_to_https is defined and http_redirect_to_https %}
{{ https_port }}
{% else %}
{{ http_port }}
{% endif %}
+ {% endif %}
{% else %}
{{ item.http_port }}
{% endif %}