Puppet set Apache Header X-Frame-Options

483 views Asked by At

I want to set the Apache's header X-Frame-Options to "Deny" by adding the following line into the httpd.conf file on a single server using puppetlaps apache module.

Header set X-Frame-Options "DENY"

I have the YAML file for the server in the ../environments/data/node/server1.yaml I can edit this file to apply the config on this server only but I don't know what to put in it.

How to call the apache module so it can add the above line into the config file?

I tried the following but didn't worked:

apache::header::x-frame-options: 'DENY'

Update: Followed the advice below but still not working in my environment, l can't find another way to do it.

1

There are 1 answers

3
Jon On

In Puppet, headers are set in an instance of an apache::vhost defined type.

https://forge.puppet.com/modules/puppetlabs/apache/7.0.0/reference#headers

You'll either need to create an apache::vhost in a manifest

apache::vhost { 'example.com':
 [...]
 headers => 'set X-Frame-Options "DENY"',
 [...]
}

or use the apache::vhosts convenience class to do the same thing in Hiera

classes:
  - apache::vhosts

apache::vhosts::vhosts:
  'example.com':
    [...]
    headers: 'set X-Frame-Options "DENY"'
    [...]