Skip to content

One-command reverse-proxy mode (ocsigenserver --reverse-proxy URL)#297

Open
balat wants to merge 4 commits into
masterfrom
reverse-proxy
Open

One-command reverse-proxy mode (ocsigenserver --reverse-proxy URL)#297
balat wants to merge 4 commits into
masterfrom
reverse-proxy

Conversation

@balat

@balat balat commented Jun 26, 2026

Copy link
Copy Markdown
Member

What

Adds a one-command reverse-proxy mode, the companion of the serve mode merged
in #296:

ocsigenserver --reverse-proxy http://localhost:9000 --port 8080

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_proxy loads the Revproxy
extension 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_server registry, 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-proxy is mutually exclusive with serving a directory and with -c.

Tests

test/reverse-proxy.t 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 the
upstream's answer relayed.

balat added 4 commits June 26, 2026 12:43
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.
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.

1 participant