Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/19875.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document lighttpd reverse proxy configuration example from matrix.jaxlug.ngo, a contribution from the JaxLUG, the Jacksonville Linux Users Group Inc..
73 changes: 71 additions & 2 deletions docs/reverse_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ It is recommended to put a reverse proxy such as
[nginx](https://nginx.org/en/docs/http/ngx_http_proxy_module.html),
[Apache](https://httpd.apache.org/docs/current/mod/mod_proxy_http.html),
[Caddy](https://caddyserver.com/docs/quick-starts/reverse-proxy),
[HAProxy](https://www.haproxy.org/) or
[relayd](https://man.openbsd.org/relayd.8) in front of Synapse.
[HAProxy](https://www.haproxy.org/),
[relayd](https://man.openbsd.org/relayd.8) or
[lighttpd](https://www.lighttpd.net/)
in front of Synapse.
This has the advantage of being able to expose the default HTTPS port (443) to Matrix
clients without requiring Synapse to bind to a privileged port (port numbers less than
1024), avoiding the need for `CAP_NET_BIND_SERVICE` or running as root.
Expand Down Expand Up @@ -312,6 +314,73 @@ relay "matrix_federation" {
}
```

### lighttpd
```conf
server.modules = (
Comment thread
anoadragon453 marked this conversation as resolved.
"mod_rewrite",
"mod_redirect",
"mod_access",
"mod_setenv",
"mod_openssl",
"mod_proxy",
"mod_accesslog"
)

server.username = "lighttpd"
server.groupname = "lighttpd"

# leave commented out for proper IPv6 see below IPv4 0.0.0.0 & IPv6 [::]
#server.use-ipv6 = "enable"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is intended as "you can use IPv6 if you want!" comment, could you add a line saying so? Otherwise it comes across as dead code/accidentally left in.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added comment, you want to ensure that is commented out.


ssl.pemfile = "/etc/lighttpd/cert+privkey.pem"
ssl.ca-file = "/etc/lighttpd/fullchain.pem"

$SERVER["socket"] == "0.0.0.0:80" { }
$SERVER["socket"] == "0.0.0.0:443" { ssl.engine = "enable" }
$SERVER["socket"] == "0.0.0.0:8448" { ssl.engine = "enable" }
$SERVER["socket"] == "[::]:80" { }
$SERVER["socket"] == "[::]:443" { ssl.engine = "enable" }
$SERVER["socket"] == "[::]:8448" { ssl.engine = "enable" }

# both lighttpd and synapse need permissions for socket r/w
$HTTP["url"] =~ "(/_matrix|_synapse/admin|/_synapse/client)" {
proxy.balance = "hash"
proxy.server = (
"" => (
"backend-socket" => (
"host" => "/var/lib/synapse/main_public.sock",
"port" => 0
)
)
)
proxy.forwarded = (
"for" => 1,
"proto" => 1,
"host" => 1,
)
}
# protect admin access IPv6 ULA only
$HTTP["remoteip"] !="fd00::/8" {
$HTTP["url"] =~ "^/_synapse/admin/" {
url.access-deny = ( "" )
}
}
```

[Delegation](delegate.md) example:
```conf
url.rewrite-once = (
"^/\.well-known/matrix/client$" => "/.well-known/matrix/client.json",
"^/\.well-known/matrix/server$" => "/.well-known/matrix/server.json"
)

# This condition intentionally matches the post-rewrite URLs.
$HTTP["url"] =~ "^/\.well-known/matrix/(client|server)\.json$" {
mimetype.assign = ( ".json" => "application/json" )
setenv.set-response-header = ( "Access-Control-Allow-Origin" => "*" )
}
```


## Health check endpoint

Expand Down