umputun / reproxy

Simple edge server / reverse proxy
http://reproxy.io
MIT License
1.21k stars 90 forks source link

Limit IPs #166

Closed umputun closed 7 months ago

umputun commented 7 months ago

Implements #119

This PR adds support for the "remote" configuration parameter to all the providers except the basic one (static). If set, it will restrict access to a given route for source IPs or networks. This is what it looks like with the file provider:

srv.example.com:
  - {route: "/something/restricted", dest: "http://127.0.0.2:8082/", "remote": "192.168.1.0/24, 124.0.0.1"}
  - {route: "^/api/svc2/(.*)", dest: "http://127.0.0.2:8080/blah2/$1/abc"} 

By default, the remote address from the request is used, however in some cases (proxy in front, docker with bridge network, etc) user may want to use X-Real-IP and X-Forwarded-For headers. This options is off by default, and to turn it on --remote-lookup-headers param or REMOTE_LOOKUP_HEADERS=1 env can be set. It should be used only in trusted environments where bad actors can't set/change those headers.