Giter VIP home page Giter VIP logo

cloudflare-nginx-ips's Introduction

cloudflare-nginx-ips

A script to handle automated IP grabbing from nginx which allows it to setup real ips and setup ufw rules for only cloudflare traffic or setup site cloudflare whitelists for nginx

Why

Stops your site leaking outsite of cloudflare, increasing your security by stopping people from finding your sites origin IP.

It also sets up the real IP module for nginx which is useful for getting the real IPs of users instead of cloudflares IPs.

Real ips

The script will handle the real ips generation and setting for you so you can see your visitors real ips

ufw rules (recommended)

The script can add ufw rules for cloudflare ips to only allow them on ports 443, 80. This mode can be disabled however, and selective geo whitelists for sites can be used instead. This mode should ideally be on as your site might send an SSL certificate and other data that may help fingerprint your server... if there is no reason in your configuration to expose nginx without cloudflare, then why do it.

Despite being recommended, ufw rule adding is off by default. to enable edit the script and set UFW_RULES to true

If you wish to only allow cloudflare IP's add this to your site block for each host (with ufw mode off)

if ($cloudflare_ip != 1) {
	return 403;
}

This will return a 403 to any visitor not from cloudflare, ideally you should enable ufw rules instead to not expose nginx, however a benefit of this is you can selectively choose which hosts are cloudflare only and which arent.

Job

Run monthly (or whenever really) in a crontab

@monthly /bin/bash /etc/nginx/cloudflare-ips.sh

cloudflare-nginx-ips's People

Contributors

itsjfx 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.