Skip to content

Commit 1aeec47

Browse files
committed
Update web.xml config to add HTTP Header Security (by default)
1 parent 20ef88b commit 1aeec47

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ tomcat_checksum_url: "https://downloads.apache.org/tomcat/tomcat-{{ tomcat_major
2222
tomcat_packages:
2323
- "tomcat{{ tomcat_major_version }}"
2424

25+
tomcat_secure_http_headers: true
26+
2527
########################################
2628
# Security Variables
2729
########################################

tasks/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,28 @@
6767
when: tomcat_conf_found.stat.exists == false
6868
tags: ['tomcat']
6969

70+
- name: Add HTTP Header Security Filter to web.xml
71+
ansible.builtin.blockinfile:
72+
path: "{{ _tomcat_catalina_base }}/conf/web.xml"
73+
insertbefore: "</web-app>"
74+
marker: "<!-- {mark} ANSIBLE MANAGED HTTP HEADER SECURITY FILTER -->"
75+
block: |
76+
<filter>
77+
<filter-name>httpHeaderSecurity</filter-name>
78+
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
79+
<init-param>
80+
<param-name>antiClickJackingOption</param-name>
81+
<param-value>SAMEORIGIN</param-value>
82+
</init-param>
83+
</filter>
84+
<filter-mapping>
85+
<filter-name>httpHeaderSecurity</filter-name>
86+
<url-pattern>/*</url-pattern>
87+
<dispatcher>REQUEST</dispatcher>
88+
</filter-mapping>
89+
when: tomcat_secure_http_headers
90+
tags: ['tomcat']
91+
7092
- name: secure catalina base config files
7193
file:
7294
path: '{{ _tomcat_catalina_base }}/conf/{{ item }}'

0 commit comments

Comments
 (0)