Last active
December 15, 2015 23:09
-
-
Save andreimaxim/5338303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This block requires the geo module, which enables the use of | |
# variables which depend on the IP address of the client. | |
# | |
# In this case, everyone outside of the 192.168.0.x network | |
# is considered an "external" client. | |
geo $external { | |
default 1; | |
192.168.0.0/24 0; | |
} | |
server { | |
listen 192.168.0.1:80; | |
server_name example.com; | |
# Redirect all requests from the external IPs to an | |
# unauthorized page. | |
if ($external) { | |
rewrite ^ /unauthorized.html last; | |
} | |
try_files $uri $uri.html $uri/index.html =404; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 192.168.0.1:80; | |
server_name example.com; | |
location / { | |
# This line determines the access policy based on multiple | |
# access handles, meaning it will let the user pass if any | |
# of the following conditions are fulfilled: | |
# | |
# * the IP address belongs to the 192.168.0.x range | |
# * the username and password match those on file in users.conf | |
satisfy any; | |
allow 192.168.0.0/24; | |
deny all; | |
auth_basic "Restricted Access"; | |
auth_basic_user_file users.conf; | |
try_files $uri $uri.html $uri/index.html =404; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment