Skip to content

Instantly share code, notes, and snippets.

@tunght13488
Last active May 16, 2019 15:32
Show Gist options
  • Save tunght13488/b955302dcb45afb1cfa9 to your computer and use it in GitHub Desktop.
Save tunght13488/b955302dcb45afb1cfa9 to your computer and use it in GitHub Desktop.

Revisions

  1. tunght13488 revised this gist Nov 4, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .htaccess
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    # See: http://www.jonathanquail.com/blog/2012/05/09/restricting-access-to-servers-behind-an-elastic-load-balancer/
    # Extract client IP
    SetEnvIf REMOTE_ADDR "(.+)" CLIENTIP=$1
    #SetEnvIf REMOTE_ADDR "(.+)" CLIENTIP=$1
    # If request is forwarded, use forwarded IP instead
    SetEnvIf X-Forwarded-For "^([0-9.]+)" CLIENTIP=$1
    # If request is not forwarded, set a flag
  2. tunght13488 created this gist Nov 4, 2015.
    18 changes: 18 additions & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # Extract client IP
    SetEnvIf REMOTE_ADDR "(.+)" CLIENTIP=$1
    # If request is forwarded, use forwarded IP instead
    SetEnvIf X-Forwarded-For "^([0-9.]+)" CLIENTIP=$1
    # If request is not forwarded, set a flag
    SetEnvIf X-Forwarded-For "^$" is_not_forwarded
    # Whitelist
    SetEnvIf CLIENTIP "173.55.53.87" allowed_in
    SetEnvIf CLIENTIP "72.67.47.197" allowed_in
    # Rules
    Order deny,allow
    Deny from all
    # Allow whitelisted forwarded IP
    Allow from env=allowed_in
    # Allow request which is not forwarded (healthcheck)
    Allow from env=is_not_forwarded
    # Remove comment from the following line to let everyone in
    #Allow from all