Giter Club home page Giter Club logo

rproxy's Introduction

rproxy

A super simple HTTP/1.1 proxy, with TLS and Let's Encrypt support.

rproxy takes care of your Let's Encrypt certificates, automatically renewing them. This is done by the excellent txacme library.

Install from PyPI:

$ pip install rproxy

Make a directory to store your certificates:

$ mkdir my-certs

Make a rproxy.ini:

[rproxy]
certificates=my-certs
http_ports=80
https_ports=443

[hosts]
mysite.com_port=8080

Then run it:

sudo twistd -u nobody -g nobody -n rproxy

This will start the server, drop permissions (setting the effective uid/guid to nobody), and will proxy incoming requests to mysite.com to localhost:8080. You can configure it further:

[rproxy]
certificates=my-certs
http_ports=80,8080
https_ports=443
clacks=true

[hosts]
mysite.com_port=8080
mysite.com_host=otherserver
mysite.com_onlysecure=True
mysite.com_proxysecure=True

myothersite.net_port=8081

This config will:

  • connect to https://otherserver:8080 as the proxied server for mysite.com, and only allow HTTPS connections to the proxy for this site
  • connect to http://localhost:8081 as the proxied server for myothersite.net, and allow HTTP or HTTPS connections.

General Config

  • http_ports -- comma-separated list of numerical ports to listen on for HTTP connections.
  • https_ports -- comma-separated list of numerical ports to listen on for HTTPS connections.
  • certificates -- directory where certificates are kept.
  • clacks -- Enable X-Clacks-Overhead for requests.

Hosts Config

  • <host>_onlysecure -- enforce HTTPS connections. If not set, or set to False, it will allow HTTP and HTTPS connections.
  • <host>_proxysecure -- connect to the proxied server by HTTPS. If not set, or set to False, it will connect over HTTP.
  • <host>_port -- The port of the proxied server that this proxy should connect to.
  • <host>_host -- the hostname/IP of the server to proxy to.
  • <host>_sendhsts -- send HSTS headers on HTTPS connections.
  • <host>_wwwtoo -- match www too.

rproxy's People

Contributors

hawkowl avatar lukasa avatar glyph avatar cliffckerr avatar cdunklau avatar

Stargazers

Hrachya Arshakyan avatar  avatar Mohsen Nasiri avatar Luis Fernando Barrera avatar Dmytro Vasylyshyn avatar Sviatoslav Sydorenko (Святослав Сидоренко) avatar Iyanuoluwa Ajao avatar  avatar James Campbell avatar  avatar Tasnim Ali avatar Amine Bendouil avatar Marcos Bomfim  avatar Kent Gruber avatar GAURAV avatar  avatar  avatar  avatar  avatar Jeremy W. Sherman avatar Andy Freeland avatar Wilfredo Sánchez Vega avatar  avatar Kali Kaneko avatar  avatar Moritz Schlarb avatar Zhao Xiaohong avatar Jürgen Hermann avatar  avatar R Max Espinoza avatar Mash Kyrielight avatar Leonardo Santagada avatar Nikolay Kolev avatar  avatar Mike Taylor avatar Saúl Ibarra Corretgé avatar Dave Forgac avatar Isaul Vargas avatar Rikard Anglerud avatar

Watchers

Neustradamus avatar Árni Már Jónsson avatar James Cloos avatar Hrachya Arshakyan avatar  avatar  avatar

rproxy's Issues

Truncates existing certs on restart?

It seems like rproxy is truncating existing certs on restart. Looks like this might be the culprit:

for host in hosts.keys():
with open(FilePath(certificates).child(host + ".pem").path, 'w'):
# Open it so that txacme can find it
pass
if hosts[host]["wwwtoo"]:
with open(FilePath(certificates).child("www." + host + ".pem").path, 'w'):
# Open it so that txacme can find it
pass

I haven't dug into the code in earnest yet, but I'm pretty sure that happens unconditionally. I suspect those two open() calls should use the 'r+' mode to avoid truncating an existing file.

Support TOML configuration

.ini is nice sometimes, but ad-hoc namespacing with _ separators and lists with , separators looks like you're practically begging for TOML.

I could make a PR for this that allows rproxy.ini and rproxy.toml both and decides how to parse it on extension.

Support LE staging API

Ideally rproxy/txacme would hit the staging server first to double check everything is fine... but rproxy should at least support hitting the staging server if configured that way. Had a bit of snafu with rate limits today :|

Renewed certs are not used

This is not a bug in rproxy per se, it lies with txsni. I'm posting it here to keep rproxy users in the loop.

While the txacme AcmeIssuingService successfully renews certs, the new certs aren't used by rproxy. This is reported in glyph/txsni#12 and fixed in glyph/txsni#22 but that fix hasn't made it to a release yet and should be in the v0.2.0 release. Restarting rproxy works around this.

Custom additional headers.

While it's nice that HSTS and clacks have both been special-cased, it remains the case that it is impossible to flatly add extra headers to rproxy because it unconditionally overwrites the response headers with the ones received from the backend. Given that one of the great use-cases of reverse proxying is the addition of extra headers without modifying a backend, it'd be neat to be able to add extra headers to a host.

gzip compression

Currently requests from rproxy to the origin will allow the origin response to be compressed, where supported. However, requests from the client to rproxy will never receive a compressed response.

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.