Coder Social home page Coder Social logo

ar-ngxrealip's Introduction

ArvanCloud Real Visitor IP

logo

This project aims to modify your Nginx configuration to let you get the actual IP address of your visitors for your web applications that are behind of ArvanCloud’s reverse proxy network. You can schedule this bash script to create an automated up-to-date ArvanCloud IP list file.

To provide the client (visitor) IP address for every request to the origin, ArvanCloud adds the “ar-real-ip” header. We will catch the header and get the actual IP address of the visitor.

  1. Create a bash script file in your desired location:

    sudo nano /var/arvancloud-sync-ips-for-nginx.sh
  2. Copy arvancloud-sync-ips-for-nginx.sh's content and save the file.

  3. Set the proper permission for the file so it can be executed:

    sudo chmod 775 /var/arvancloud-sync-ips-for-nginx.sh
  4. Now you can run the script manually to create the Nginx config file:

    sudo /var/arvancloud-sync-ips-for-nginx.sh
  5. Or schedule a new cronjob to do it automatically at regular intervals (e.g: every day at 2:30 a.m.)

    sudo crontab -e
    
    # Auto sync IP addresses of ArvanCloud and reload the Nginx
    30 2 * * * /var/arvancloud-sync-ips-for-nginx.sh >/dev/null 2>&1

Output

Now if you check /etc/nginx/conf.d directory you should see a new file named arvancloud-set-real-ip.conf which will be included in your Nginx configs automatically and sets the actual IP address for upcoming requests.

The output should be like the below:

#ArvanCloud

# - IPv4
set_real_ip_from 185.143.232.0/22;
set_real_ip_from 92.114.16.80/28;
set_real_ip_from 2.146.0.0/28;
set_real_ip_from 46.224.2.32/29;
set_real_ip_from 83.123.255.56/31;
set_real_ip_from 188.229.116.16/29;
set_real_ip_from 164.138.128.28/31;
set_real_ip_from 94.182.182.28/30;
set_real_ip_from 185.17.115.176/30;
set_real_ip_from 5.213.255.36/31;
set_real_ip_from 185.228.238.0/28;
set_real_ip_from 94.182.153.24/29;
set_real_ip_from 94.101.182.0/27;
set_real_ip_from 158.255.77.238/31;
set_real_ip_from 81.12.28.16/29;
set_real_ip_from 176.65.192.202/31;
set_real_ip_from 2.144.3.128/28;
set_real_ip_from 89.45.48.64/28;
set_real_ip_from 37.32.16.0/27;
set_real_ip_from 37.32.17.0/27;
set_real_ip_from 37.32.18.0/27;
set_real_ip_from 37.32.19.0/27;
set_real_ip_from 185.215.232.0/22;

real_ip_header ar-real-ip;

ar-ngxrealip's People

Contributors

3a8r avatar 3aaber avatar arastu avatar hatamiarash7 avatar mhyeganeh avatar salehirandom avatar timcheh avatar yzdann avatar

Stargazers

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