Giter VIP home page Giter VIP logo

proxy-1's Introduction

WARNING: This is a pre-release version and is not suitable for production use. It is for evaluation purposes only. Please report all bugs by creating a issue, or by contacting us directly.

ip-api cache

A proxy that caches query results from the ip-api.com pro endpoint.

  • better performance via multiple keep-alive connections to ip-api servers
  • finds the best PoP based on latency
  • retries failed requests
  • advanced caching for each response field
  • automatically batches requests to reduce network requests

Only /json and /batch are supported.

Getting Started

Install on Linux - Debian

  • Create a user
adduser --system --disabled-password --disabled-login --home /opt/ip-api-proxy --group ip-api-proxy
  • Install the latest version

If you do not have go installed, please see https://golang.org/doc/install.

GOBIN=/opt/ip-api-proxy/ go get -u github.com/ip-api/proxy/cmd/proxy
  • Create a config file

/opt/ip-api-proxy/config

Example configuration:

IP_API_KEY=your_api_key
LOG_LEVEL=info
  • Create a systemd file

/etc/systemd/system/ip-api-proxy.service

Suggested configuration:

[Unit]
Description=ip-api proxy server
Documentation=https://github.com/ip-api/proxy
After=network.target

[Service]
PermissionsStartOnly=true
LimitNOFILE=1048576
LimitNPROC=512
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
User=ip-api-proxy
WorkingDirectory=/opt/ip-api-proxy
EnvironmentFile=/opt/ip-api-proxy/config
ExecStart=/opt/ip-api-proxy/proxy
Restart=on-failure

[Install]
WantedBy=multi-user.target
  • Enable and start the service
systemctl enable ip-api-proxy
systemctl start ip-api-proxy

Usage

Modify your applications to use http://127.0.0.1:8080 instead of http(s)://pro.ip-api.com.

Environment variables

Name Type Default Description
IP_API_KEY String required ip-api.com key
LISTEN String 127.0.0.1:8080 ip:port to listen on
CACHE_TTL Duration 24h For how long to cache entries
CACHE_SIZE Number 1073741824 In memory cache size
RETRIES Number 4 How many times to retry backend requests
POPS_REFRESH Duration 1h How often to refresh the server locations
BATCH_DELAY Duration 10ms Max delay before sending a batch to the backend
LOG_OUTPUT String "" Set to "console" for console friendly output
LOG_LEVEL String "" Can be set to "info", "warn" or "error" to reduce log output
REVERSE_WORKERS Number 10 How many workers to use for reverse lookups
REVERSE_PREFERGO Bool true Prefer using Go's built-in DNS resolver

proxy-1's People

Contributors

erikdubbelboer avatar vladc avatar ip-api avatar

Forkers

global19

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.