Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reverse proxy capability #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add reverse proxy capability #143

wants to merge 1 commit into from

Conversation

Quentin-M
Copy link

Because why should we limit ourselves to a forward proxy server when we could do both reverse and forward proxying at the same time?

This commit allows us to specify a ProxyHttpServer in NewProxyHttpServer that will act as a reverse proxy when the forward proxy constructed will be called as a reverse proxy. When no reverse proxy is specified and the forward proxy is called as a reverse proxy, a response with status code 500 and message This is a proxy server. Does not respond to non-proxy requests., just like before.

@elazarl
Copy link
Owner

elazarl commented Mar 12, 2016

Hi,

What would be the advantage to the users for using goproxy as a reverse proxy? There are many other solutions which are probably superior.

I'd like to understand the use case before taking a big change.

Thanks!

@Quentin-M
Copy link
Author

It allows people who need both a forward and a reverse proxy to use a single library. They can then use the same interfaces for both cases (i.e. enjoying OnRequest()).

In our use case, we can have a single server (listening on only one port) doing either request authorization/signing (ie. HMAC or JWT) or request verification depending on how it's called (as a proxy or as a reverse proxy).

@elazarl
Copy link
Owner

elazarl commented Mar 14, 2016

Sounds reasonable.

BTW, I think a better approach is, not to add isReverseProxy, but instead allow filtering regular HTTP request with the onRequest mechanism.

What do you think?

@Quentin-M
Copy link
Author

Hi,

Thanks for the response.

I noticed that we shouldn't have both the proxy and the reverse proxy on the same port, even though the idea looked nice. Some people might want to terminate TLS on the reverse proxy, however it is impossible to get a forward proxy working properly with TLS termination.

Thus, I modified and simplified slightly my PR. It now simply exposes a new constructor NewReverseProxyHttpServer() that creates a reverse proxy. The NonproxyHandler will be called when a forward proxy is called like a reverse proxy, and when a reverse proxy is called like a forward proxy.

@Quentin-M
Copy link
Author

Bump

@smintz
Copy link

smintz commented Aug 1, 2016

Hey, I was looking for same functionality and bumped into this PR, is it going to be merged?

@Quentin-M
Copy link
Author

Quentin-M commented Aug 1, 2016

Hi,

Note that in the meantime, you can use https://github.com/coreos/goproxy, which supports reverse proxies and websockets.

@smintz
Copy link

smintz commented Aug 1, 2016

cool, thanks @Quentin-M!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants