Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problems using mod_headers with php-fpm/mod_fastcgi

I'm trying to add HSTS headers to every response, across my app.

My first thought was to use mod_headers — I placed this directive in an .htaccess file at the documentroot:

Header set Strict-Transport-Security "max-age=7776000"

This works fine on my local setup using Apache 2.2 and mod_php. All resources respond with the appropriate HSTS header.

My deployment environment uses Apache 2.2 and mod_fastcgi and the above technique works for any resource except php files.

Another SO question had a similar problem, where incoming requests (?) had headers stripped — but I'm concerned about modifying headers of response leaving the server.

How can I add response headers to php resources in the context of an .htaccess file?

like image 703
Mark Fox Avatar asked Apr 18 '14 18:04

Mark Fox


1 Answers

According to the docs for mod_headers you probably need to set the optional conditional flag for the header directive.

So in this case, it would become

Header always set Strict-Transport-Security "max-age=7776000"
like image 109
Stephen Avatar answered Nov 02 '22 23:11

Stephen