Created
July 2, 2014 19:22
-
-
Save lihonosov/faaec626bf753fd1c849 to your computer and use it in GitHub Desktop.
Protecting Folders with Nginx
This file contains hidden or 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
| //Creating .htpasswd | |
| htpasswd -c /var/www/html/admin/.htpasswd username | |
| //Setting up Nginx | |
| server { | |
| listen 80; | |
| server_name domain.com www.domain.com; | |
| location / { | |
| # your normal content | |
| } | |
| location /admin { | |
| auth_basic "Administrator Login"; | |
| auth_basic_user_file /var/www/html/admin/.htpasswd; | |
| } | |
| #!!! IMPORTANT !!! We need to hide the password file from prying eyes | |
| # This will deny access to any hidden file (beginning with a .period) | |
| location ~ /\. { deny all; } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment