GithubHelp home page GithubHelp logo

nginx-uptime-filter's Introduction

Nginx uptime filter

It is an serie of Nginx configuration files that allow you filter requests made from the major uptime platforms. You can use that to allow only a country access (using GeoIP) to your application and the Pingdom too, for example. It's preatty easy to use and very helpfull.

We will maintain the IPv4 and IPv6 address range for all the providers with the option to use each one or both.

Installation

git clone https://github.com/Arenhardt/nginx-uptime-filter.git

Pingdom IPv4 install on Debian based SO (Debian, Ubuntu, Kubuntu, etc):

sudo cp -r nginx-uptime-filter/nginx/conf.d/pingdomv4.conf /etc/nginx/conf.d/pingdom.conf

For IPv6 filter:

sudo cp -r nginx-uptime-filter/nginx/conf.d/pingdomv6.conf /etc/nginx/conf.d/pingdom.conf

And for both (IPv4 and IPv6):

sudo cp -r nginx-uptime-filter/nginx/conf.d/pingdomv4_v6.conf /etc/nginx/conf.d/pingdom.conf

Than follow the examples to usage in the Nginx global environment or inside a single vhost.

Examples

See some usage examples

Deny example if the requester is a Pingdom agent:

if ($is_pingdom = 1) {
    # your stufs here if the request is made from Pingdom
    ex: Deny
    return 403 "You shaw not pass!";
}

Allow example if the requester is an UptimeRobot agent:

if ($is_uptimerobot = 1) {
    # your stufs here if the request is made from Pingdom
    ex: Allow
    return 200 "Ok, i'm alive";
}

Complex flow:

# verify if is a Pingdom request
if ($is_pingdom = 1) {
    set $rule 1$rule;
}
# verify if request method is GET
if ($request_method = GET ) {
    set $rule 2$rule;
}
# if is Pingdom and the request method is GET, so rewrite
if ($rule = "21"){
    rewrite . https://domain.com/ permanent;
}

Other one:

# verify if is a Pingdom request
if ($is_pingdom = 1) {
    set $rule 1$rule;
}
# verify if is a UptimeRobot request
if ($is_uptimerobot = 1) {
    set $rule 2$rule;
}
# verify if request method is POST
if ($request_method = GET ) {
    set $rule 3$rule;
}
# if is UptimeRobot, the request method is GET and is not Pingdom, so rewrite
if ($rule = "32"){
    rewrite . https://domain.com/no_pingdom.html permanent;
}

TODO

  • Installation system
  • Add more providers
  • Script to update the providers base

nginx-uptime-filter's People

Contributors

arenhardt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.