diff options
| author | Christian Cleberg <[email protected]> | 2025-11-11 22:49:13 -0600 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2025-11-11 22:49:13 -0600 |
| commit | 51a7a02f0c96d49b68fbcc155414c218207fa270 (patch) | |
| tree | 845af8aad0e8769352efc02fcd1044eed9cc1ec1 /content/blog/2022-11-29-nginx-referrer-ban-list.org | |
| parent | 7d3e80ebf1dc770eac0e21890b74f18ba2d15a6b (diff) | |
| download | cleberg.net-51a7a02f0c96d49b68fbcc155414c218207fa270.tar.gz cleberg.net-51a7a02f0c96d49b68fbcc155414c218207fa270.tar.bz2 cleberg.net-51a7a02f0c96d49b68fbcc155414c218207fa270.zip | |
fix grammar in 2022 posts
Diffstat (limited to 'content/blog/2022-11-29-nginx-referrer-ban-list.org')
| -rw-r--r-- | content/blog/2022-11-29-nginx-referrer-ban-list.org | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/content/blog/2022-11-29-nginx-referrer-ban-list.org b/content/blog/2022-11-29-nginx-referrer-ban-list.org index 0e7d72c..59fbe29 100644 --- a/content/blog/2022-11-29-nginx-referrer-ban-list.org +++ b/content/blog/2022-11-29-nginx-referrer-ban-list.org @@ -5,9 +5,9 @@ * Creating the Ban List -In order to ban list referral domains or websites with Nginx, you need -to create a ban list file. The file below will accept regexes for -different domains or websites you wish to block. +In order to ban list referral domains or websites with Nginx, you need to create +a ban list file. The file below will accept regexes for different domains or +websites you wish to block. First, create the file in your nginx directory: @@ -15,8 +15,8 @@ First, create the file in your nginx directory: doas nano /etc/nginx/banlist.conf #+end_src -Next, paste the following contents in and fill out the regexes with -whichever domains you're blocking. +Next, paste the following contents in and fill out the regexes with whichever +domains you're blocking. #+begin_src conf # /etc/nginx/banlist.conf @@ -33,15 +33,15 @@ map $http_referer $bad_referer { * Configuring Nginx -In order for the ban list to work, Nginx needs to know it exists and how -to handle it. For this, edit the =nginx.conf= file. +In order for the ban list to work, Nginx needs to know it exists and how to +handle it. For this, edit the =nginx.conf= file. #+begin_src sh doas nano /etc/nginx/nginx.conf #+end_src -Within this file, find the =http= block and add your ban list file -location to the end of the block. +Within this file, find the =http= block and add your ban list file location to +the end of the block. #+begin_src conf # /etc/nginx/nginx.conf @@ -56,23 +56,22 @@ http { * Enabling the Ban List -Finally, we need to take action when a bad referral site is found. To do -so, edit the configuration file for your website. For example, I have -all website configuration files in the =http.d= directory. You may have -them in the =sites-available= directory on some distributions. +Finally, we need to take action when a bad referral site is found. To do so, +edit the configuration file for your website. For example, I have all website +configuration files in the =http.d= directory. You may have them in the +=sites-available= directory on some distributions. #+begin_src sh doas nano /etc/nginx/http.d/example.com.conf #+end_src -Within each website's configuration file, edit the =server= blocks that -are listening to ports 80 and 443 and create a check for the -=$bad_referrer= variable we created in the ban list file. +Within each website's configuration file, edit the =server= blocks that are +listening to ports 80 and 443 and create a check for the =$bad_referrer= +variable we created in the ban list file. -If a matching site is found, you can return any -[[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes][HTTP Status -Code]] you want. Code 403 (Forbidden) is logical in this case since you -are preventing a client connection due to a banned domain. +If a matching site is found, you can return any [[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes][HTTP Status Code]] you want. Code +403 (Forbidden) is logical in this case since you are preventing a client +connection due to a banned domain. #+begin_src conf server { @@ -97,8 +96,8 @@ doas rc-service nginx restart * Testing Results -In order to test the results, let's curl the contents of our site. To -start, I'll curl the site normally: +In order to test the results, let's curl the contents of our site. To start, +I'll curl the site normally: #+begin_src sh curl https://cleberg.net @@ -117,8 +116,8 @@ curl --referer https://news.ycombinator.com https://cleberg.net #+end_src This time, I'm met with a 403 Forbidden response page. That means we are -successful and any clients being referred from a banned domain will be -met with this same response code. +successful and any clients being referred from a banned domain will be met with +this same response code. #+begin_src html <html> |
