Configuration options, tweak challenge, update readme

This commit is contained in:
simon987 2020-03-02 15:47:34 -05:00
parent 24fb11fe0d
commit 3aed336a3c
4 changed files with 270 additions and 107 deletions

View File

@ -123,7 +123,7 @@ is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Component, and (b) serves only to enabled use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html_path>.

View File

@ -3,7 +3,6 @@
![GitHub](https://img.shields.io/github/license/simon987/ngx_http_js_challenge_module.svg)
[![CodeFactor](https://www.codefactor.io/repository/github/simon987/ngx_http_js_challenge_module/badge)](https://www.codefactor.io/repository/github/simon987/ngx_http_js_challenge_module)
[![Development snapshots](https://ci.simon987.net/app/rest/builds/buildType(JsChallenge_Build)/statusIcon)](https://files.simon987.net/artifacts/JsChallenge/Build/)
Simple javascript proof-of-work based access for Nginx with virtually no overhead.
@ -16,13 +15,69 @@ Easy installation: just add `load_module /path/to/ngx_http_js_challenge_module.s
### Configuration
//todo
**Simple configuration**
```nginx
server {
js_challenge on;
js_challenge_secret "change me!";
# ...
}
```
**Advanced configuration**
```nginx
server {
js_challenge on;
js_challenge_secret "change me!";
js_challenge_html /path/to/body.html;
js_challenge_bucket_duration 3600;
js_challenge_title "Verifying your browser...";
location /static {
js_challenge off;
alias /static_files/;
}
location /sensitive {
js_challenge_bucket_duration 600;
#...
}
#...
}
```
* `js_challenge on|off` Toggle javascript challenges for this config block
* `js_challenge_secret "secret"` Secret for generating the challenges. DEFAULT: "changeme"
* `js_challenge_html "/path/to/file.html"` Path to html file to be inserted in the `<body>` tag of the interstitial page
* `js_challenge_title "title"` Will be inserted in the `<title>` tag of the interstitial page. DEFAULT "Verifying your browser..."
* `js_challenge_bucket_duration time` Interval to prompt js challenge, in seconds. DEFAULT: 3600
### Installation
1. Add `load_module ngx_http_js_challenge_module.so;` to `/etc/nginx/nginx.conf`
1. Reload `nginx -s reload`
### Build from source
//todo
These steps have to be performed on machine with compatible configuration (same nginx, glibc, openssl version etc.)
```bash
apt install libperl-dev libgeoip-dev libgd-dev libxslt1-dev
```
1. Install dependencies
```bash
apt install libperl-dev libgeoip-dev libgd-dev libxslt1-dev
```
2. Download nginx tarball corresponding to your current version (Check with `nginx -v`)
```bash
wget https://nginx.org/download/nginx-1.16.1.tar.gz
tar -xzf nginx-1.16.1.tar.gz
export NGINX_PATH=$(pwd)/nginx-1.16.1/
```
3. Compile the module
```bash
git clone https://github.com/simon987/ngx_http_js_challenge_module
cd ngx_http_js_challenge_module
./build.sh
```
4. The dynamic module can be found at `${NGINX_PATH}/objs/ngx_http_js_challenge_module.so`

View File

@ -1,20 +1,16 @@
NGINX_PATH=/home/simon/Downloads/nginx-1.16.1/
if [ -z ${NGINX_PATH+x} ]; then
echo "Please set the NGINX_PATH variable";
exit
fi
MODULE_PATH=$(pwd)/
CONFIG_ARGS=$(nginx -V 2>&1 | tail -n 1 | cut -c 21- | sed 's/--add-dynamic-module=.*//g')
CONFIG_ARGS="${CONFIG_ARGS} --add-dynamic-module=${MODULE_PATH}"
echo $CONFIG_ARGS
(
cd ${NGINX_PATH}
#bash -c "./configure ${CONFIG_ARGS}"
make modules
#cp objs/ "${WD}"
cd ${NGINX_PATH} || exit
bash -c "./configure ${CONFIG_ARGS}"
make modules -j "$(nproc)"
)
rm /test/*.so
mv /home/simon/Downloads/nginx-1.16.1/objs/ngx_http_js_challenge_module.so /test/module.so
chown -R www-data /test/
systemctl restart nginx

File diff suppressed because one or more lines are too long