Skip to content

Reverse Proxy

User65k edited this page Apr 14, 2024 · 4 revisions

Config

Specify at least the key forward in a mount path.

subkey meaning
forward URL of the upstream server. proto://target_server/path
proto can be http, https or h2 (HTTP2 Prior Knowledge)
add_forwarded_header Optional bool. If true add the Forwarded Header on the way to the upstream server. All existing IPs will be added separated by comma. host will be the servername used in the request.
If false, the header will be removed if present.
If not set, the header will be added, but existing IPs will be ignored
add_via_header_to_server Optional Name to insert into the Via Header sent to the upstream server. All existing Via headers will be added separated by comma. If not specified, the header will be removed if present
add_via_header_to_client Optional Name to insert into the Via Header sent back to the requestor. All existing Via headers will be added separated by comma. If not specified, the header will be removed if present
add_x_forwarded_for_header Optional bool. If true add the X-Forwarded-For Header on the way to the upstream server. All existing IPs will be added separated by comma. If false (default), the header will be removed if present
force_dir Optional bool. If true (default) ensure that the mount point is used as a directory. Requests to http://server/mount would be redirected to http://server/mount/. This enables the upstream server to use relative links. Turn it of to forward a single Websocket.
h1_pool_size Optional maximum concurrent connections to a http/1.1 server
tls_root Required for https Path to CA certificate
allowed_upgrades Optional List of upgrades that will be allowed. Defaults to everything but h2c
allowed_methods Optional List of methods that will be allowed. Defaults to everything but CONNECT
filter_req_header Optional List of forwarded headers. Everything else will be stripped. Defaults to all are allowed
filter_resp_header Optional List of returned headers. Everything else will be stripped. Defaults to all are allowed

Examples

Forward requests from /stuff/ to http://upstream/folder/.

  • /stuff/test?abc -> http://upstream/folder/test?abc
  • /stuff/a/b/c -> http://upstream/folder/a/b/c
  • /stuff -> /stuff/
["example.com".stuff] # /stuff/* will go to http://upstream/folder/*
forward = "http://upstream/folder/"

Forward requests from /stuff to http://upstream/websocket.

["example.com".websocket]
forward = "http://upstream/websocket"
force_dir = false

Clone this wiki locally