One-command reverse-proxy mode (ocsigenserver --reverse-proxy URL)#297
Open
balat wants to merge 4 commits into
Open
One-command reverse-proxy mode (ocsigenserver --reverse-proxy URL)#297balat wants to merge 4 commits into
balat wants to merge 4 commits into
Conversation
Server.reverse_proxy forwards every request to a base URL with no configuration file, in the same spirit as the serve mode. The Revproxy extension is loaded dynamically on demand and publishes its forwarding function through the new Server.register_reverse_proxy_server registry, so it need not be statically linked. The common setup (stderr logging, temporary command pipe, on-demand extension loading) shared with the serve mode is factored into helpers.
"ocsigenserver --reverse-proxy URL" forwards every request to URL. It is mutually exclusive with serving a directory and with -c, and honours --port.
Starts an upstream serve-mode server and a reverse proxy in front of it, and checks that a request to the proxy is forwarded and its answer relayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a one-command reverse-proxy mode, the companion of the serve mode merged
in #296:
Every request is forwarded to the given base URL, with no configuration file
and no log directory required.
Design
Same pattern as the serve mode:
Server.reverse_proxyloads the Revproxyextension dynamically on demand (so it is not statically linked and the
configuration-file path is unaffected). Revproxy publishes a
"forward everything to URL" function through the new
Server.register_reverse_proxy_serverregistry, which builds a redirection(.*)->URL/\1. The setup shared with the serve mode (stderr logging,temporary command pipe, on-demand extension loading) is factored into helpers.
--reverse-proxyis mutually exclusive with serving a directory and with-c.Tests
test/reverse-proxy.tstarts an upstream serve-mode server and a reverse proxyin front of it, and checks that a request to the proxy is forwarded and the
upstream's answer relayed.