From a17754f641e52c883a150dcb5dc5416910398b09 Mon Sep 17 00:00:00 2001 From: tfasano1 Date: Wed, 30 Jun 2021 20:25:11 -0400 Subject: added basic auth tutorial (with svg haha) --- auth.html | 131 ++++++ pix/auth.svg | 1461 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tor.html | 2 +- 3 files changed, 1593 insertions(+), 1 deletion(-) create mode 100644 auth.html create mode 100644 pix/auth.svg diff --git a/auth.html b/auth.html new file mode 100644 index 0000000..72ef15e --- /dev/null +++ b/auth.html @@ -0,0 +1,131 @@ + + + + HTTP Basic Authentication + + + + + + + +

Access Control with HTTP Basic Auth

+ +
+ access control with nginx +

HTTP basic authentication will allow you to secure parts (or all) of your website with a user name and password without the trouble of php or javascript.

+ +

Installation

+

We will be using the command htpasswd to make username and password pairs.

+
apt install apache2-utils
+ + +

+ Now think of a username and password and remember them. +

+ +
htpasswd -c /etc/apache2/myusers username
+ +

+ Type out your password twice to confirm. You can do this as many times as you'd like. +

+

Check out user name password pairs:

+
cat /etc/apache2/myusers
+ +

Nginx Config and Auth Basic

+

+ From here, we are going to edit our websites config file in /etc/nginx/sites-enabled. + Have in mind which folder you'd like to secure. Add something like this: +

+ +
server {
+    #...
+    location /secret-folder  {
+        auth_basic "What's the Password?" ;
+        auth_basic_user_file /etc/apache2/myusers ;
+    }
+    #...
+}
+ + +

If you'd like to do the opposite, such as making the entire site private except for a public section, do this:

+
server {
+    #...
+    auth_basic "What's the Password?" ;
+    auth_basic_user_file /etc/apache2/myusers ;
+    location /public/ {
+        #...
+        auth_basic off ;
+    }
+    #...
+}
+

IP Addresses

+

If passwords aren't enough we can ban an ip or accept one.

+
location /api {
+    #...
+    allow 192.168.1.23:8080 ;
+    deny 127.0.0.1 ;
+}
+

If you want to check both a username and password with an ip address, use the satisfy directive.

+
location /api {
+    #...
+    satify all ;
+
+    allow 192.168.1.23:8080 ;
+    deny 127.0.0.1 ;
+
+    auth_basic "What's the Password?" ;
+    auth_basic_user_file /etc/apache2/myusers ;
+}
+

Complete Example

+
http {
+    server {
+        listen 80;
+        root /var/www/website ;
+
+        #...
+        location /secret-folder {
+            satisfy all ;
+
+            allow 192.168.1.3/24;
+            deny 127.0.0.1 ;
+
+            auth_basic "What's the Password?" ;
+            auth_basic_user_file /etc/apache2/myusers ;
+        }
+    }
+}
+ +

+ Now check your configuration with nginx -t +

+ +

Reload nginx and you're good to go!

+ + + + + + + + + + + + Contributor - tomfasano.xyz + + +
+ + + diff --git a/pix/auth.svg b/pix/auth.svg new file mode 100644 index 0000000..5b17192 --- /dev/null +++ b/pix/auth.svg @@ -0,0 +1,1461 @@ + + + + + + + + + + diff --git a/tor.html b/tor.html index db4ec64..0d54b5f 100644 --- a/tor.html +++ b/tor.html @@ -41,7 +41,7 @@ HiddenServiceDir line.

-

Now restart tor

+

Now start and enable tor at boot

 systemctl enable --now tor 

If the next command outputs active in green you're golden!

-- cgit v1.2.3 From a987b7755199689beaba3ea02ce949239e4b6d34 Mon Sep 17 00:00:00 2001 From: tfasano1 Date: Wed, 30 Jun 2021 21:36:18 -0400 Subject: added to index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index f6803ea..3c16f0e 100644 --- a/index.html +++ b/index.html @@ -51,6 +51,7 @@
  • Use your SSH keys to prevent hacking.
  • Schedule tasks with Crontabs/Cronjobs.
  • Mirror your site on Tor.
  • +
  • Control Access with HTTP Basic Authentication.
  • "Build your own platform!"

    -- cgit v1.2.3 From 08014695c87d4caf94a002cabfa22c0e800663dc Mon Sep 17 00:00:00 2001 From: tfasano1 Date: Wed, 30 Jun 2021 22:13:37 -0400 Subject: fixes --- auth.html | 11 ----------- index.html | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/auth.html b/auth.html index 72ef15e..adc5632 100644 --- a/auth.html +++ b/auth.html @@ -112,19 +112,8 @@

    Reload nginx and you're good to go!

    - - - - - - - - - - Contributor - tomfasano.xyz -
    LandChad.net
    Because Everyone should be an Internet LandChad.
  • chad
  • RSS
  • BTC
  • XMR
  • Github
  • diff --git a/index.html b/index.html index 3c16f0e..3074ed7 100644 --- a/index.html +++ b/index.html @@ -51,7 +51,7 @@
  • Use your SSH keys to prevent hacking.
  • Schedule tasks with Crontabs/Cronjobs.
  • Mirror your site on Tor.
  • -
  • Control Access with HTTP Basic Authentication.
  • +
  • Access Control with HTTP Basic Authentication.
  • "Build your own platform!"

    -- cgit v1.2.3 From 156e9cafb3162952dc4055d27da90650afc630a8 Mon Sep 17 00:00:00 2001 From: tfasano1 Date: Wed, 30 Jun 2021 22:14:07 -0400 Subject: fixes --- auth.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth.html b/auth.html index adc5632..6388452 100644 --- a/auth.html +++ b/auth.html @@ -55,7 +55,7 @@

    If you'd like to do the opposite, such as making the entire site private except for a public section, do this:

    -- cgit v1.2.3 From 28cfc20065686d48f651f6e1844d94df13ff4395 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 30 Jun 2021 23:03:21 -0400 Subject: minor branding changes and tweaks --- auth.html | 26 ++++++++++++++------------ index.html | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/auth.html b/auth.html index 6388452..6c30d7f 100644 --- a/auth.html +++ b/auth.html @@ -1,7 +1,7 @@ - HTTP Basic Authentication + Requiring Passwords for Webpages (HTTP Authentication) – LandChad.net @@ -9,25 +9,27 @@ -

    Access Control with HTTP Basic Auth

    +

    Requiring Passwords for Webpages

    - access control with nginx -

    HTTP basic authentication will allow you to secure parts (or all) of your website with a user name and password without the trouble of php or javascript.

    + access control with nginx +

    HTTP basic authentication will allow you to secure parts (or all) of your website with a username and password without the trouble of PHP or Javascript. + This will work with any Nginx server. +

    Installation

    We will be using the command htpasswd to make username and password pairs.

    apt install apache2-utils

    Now think of a username and password and remember them.

    -
    htpasswd -c /etc/apache2/myusers username
    +
    htpasswd -c /etc/nginx/myusers username