apacheamazon-web-servicesamazon-amisetenvif

How to allow incoming traffic based on User-Agent Header field with Apache


I have read the documentation on Apache's setEnvIf and, using their example, written the following httpd config file designed to only allow requests from HTTP Header User-Agent=Doug

SetEnvIfNoCase User-Agent Doug let_me_in
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None

Order deny,allow
Deny from all
Allow from env=let_me_in
</Directory>

Upon using Postman to send the request with the User-Agent being Doug, the request was denied. I have also tried switching the order to allow,deny to no avail.

I am running Amazon AMI and using Apache 2.2.31


Solution

  • Turns out this was a bug in Postman in terms of setting User-Agent HTTP header. I had the Apache configuration correct after all.