diff --git a/templates/haproxy_cfg b/templates/haproxy_cfg
index e90580927b036b8b91dbdc139658ab9b7af38e3e..905f757d6a51d047407ad9cfae5fb93072f41408 100644
--- a/templates/haproxy_cfg
+++ b/templates/haproxy_cfg
@@ -141,14 +141,14 @@ backend backend_{{ external.key }}
 {% for host in groups['all'] %}
 
 backend backend_{{host}}
-{% if host == inventory_hostname %}
+{% if host == inventory_hostname or host == 'localhost' %}
   http-response deny
 {% else %}
   server server_{{host}} {{hostvars[host]['static_ipv4']|default(hostvars[host]['ansible_default_ipv4']['address'])}}:80 maxconn 100
 {% endif %}
 
 backend backend_{{host}}_https
-{% if host == inventory_hostname %}
+{% if host == inventory_hostname or host == 'localhost' %}
   http-response deny
 {% else %}
   http-response set-header Strict-Transport-Security "max-age=16000000; includeSubDomains; preload;"