hjr3 / weldr

A HTTP 1.1 proxy written in Rust using tokio.
Apache License 2.0
218 stars 20 forks source link

Handle hostname #78

Closed yanns closed 7 years ago

yanns commented 7 years ago

to be rebased once https://github.com/hjr3/weldr/pull/77 is merged.

This PR adds the possibility to use hostnames as backends. For example:

cargo run --bin weldr 127.0.0.1:9001 https://wiki-growth.herokuapp.com/ 127.0.0.1:9002

serves https://wiki-growth.herokuapp.com/ on http://127.0.0.1:9001

cargo run --bin weldr 127.0.0.1:9001 https://github.com/ 127.0.0.1:9002

serves github on http://127.0.0.1:9001

To completely support github, we still have to translate cookies. The response header:

Set-Cookie:logged_in=no; domain=.github.com; path=/; expires=Wed, 25 Feb 2037 13:48:23 -0000; secure; HttpOnly

must be translated for the proxy host name / secure or not.

And all cookie request headers must also be translated. I propose to add an issue for that and address this in another PR.

hjr3 commented 7 years ago

awesome! I was going to make this same change to store Url in the server.

yanns commented 7 years ago

I made the host mapping configurable, in a very simple way. Now using heroku works like this:

cargo run --bin weldr 127.0.0.1:9001 https://wiki-growth.herokuapp.com/ 127.0.0.1:9002 true

I guess this is the minimal before starting a proper configuration.

hjr3 commented 7 years ago

Awesome! Thank you for all the work.