Skip to content

Instantly share code, notes, and snippets.

@dsmrt
Last active July 25, 2016 16:46
Show Gist options
  • Select an option

  • Save dsmrt/abd067afdafc40caf73120fe173d9ddb to your computer and use it in GitHub Desktop.

Select an option

Save dsmrt/abd067afdafc40caf73120fe173d9ddb to your computer and use it in GitHub Desktop.
Whitelist a IP using htauth (apahce 2.4) when it's behind a Elastic Load Balancer
<Directory "/var/www/html/public/">
DirectoryIndex index.php index.html index.htm
ErrorDocument 404 index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
AuthType Basic
AuthName "My Protected Area"
AuthUserFile /path/to/authfile/.htpasswd
SetEnvIF X-Forwarded-For "0.0.0.0" AllowIP #change 0.0.0.0 to your whitelisted ip
<RequireAny>
Require valid-user
Require env AllowIP
</RequireAny>
</Directory>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment