Formatting for reverse-proxy docs (#7514)

also a small clarification to nginx
pull/7516/head
Richard van der Hoff 2020-05-15 15:13:39 +01:00 committed by GitHub
parent 572b444dab
commit 24d9151a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 75 additions and 64 deletions

1
changelog.d/7514.doc Normal file
View File

@ -0,0 +1 @@
Improve the formatting of `reverse_proxy.md`.

View File

@ -34,7 +34,8 @@ the reverse proxy and the homeserver.
### nginx ### nginx
server { ```
server {
listen 443 ssl; listen 443 ssl;
listen [::]:443 ssl; listen [::]:443 ssl;
server_name matrix.example.com; server_name matrix.example.com;
@ -46,9 +47,9 @@ the reverse proxy and the homeserver.
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
client_max_body_size 10M; client_max_body_size 10M;
} }
} }
server { server {
listen 8448 ssl default_server; listen 8448 ssl default_server;
listen [::]:8448 ssl default_server; listen [::]:8448 ssl default_server;
server_name example.com; server_name example.com;
@ -57,60 +58,68 @@ the reverse proxy and the homeserver.
proxy_pass http://localhost:8008; proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;
} }
} }
```
> **NOTE**: Do not add a `/` after the port in `proxy_pass`, otherwise nginx will **NOTE**: Do not add a path after the port in `proxy_pass`, otherwise nginx will
canonicalise/normalise the URI. canonicalise/normalise the URI.
### Caddy 1 ### Caddy 1
matrix.example.com { ```
matrix.example.com {
proxy /_matrix http://localhost:8008 { proxy /_matrix http://localhost:8008 {
transparent transparent
} }
} }
example.com:8448 { example.com:8448 {
proxy / http://localhost:8008 { proxy / http://localhost:8008 {
transparent transparent
} }
} }
```
### Caddy 2 ### Caddy 2
matrix.example.com { ```
matrix.example.com {
reverse_proxy /_matrix/* http://localhost:8008 reverse_proxy /_matrix/* http://localhost:8008
} }
example.com:8448 { example.com:8448 {
reverse_proxy http://localhost:8008 reverse_proxy http://localhost:8008
} }
```
### Apache ### Apache
<VirtualHost *:443> ```
<VirtualHost *:443>
SSLEngine on SSLEngine on
ServerName matrix.example.com; ServerName matrix.example.com;
AllowEncodedSlashes NoDecode AllowEncodedSlashes NoDecode
ProxyPass /_matrix http://127.0.0.1:8008/_matrix nocanon ProxyPass /_matrix http://127.0.0.1:8008/_matrix nocanon
ProxyPassReverse /_matrix http://127.0.0.1:8008/_matrix ProxyPassReverse /_matrix http://127.0.0.1:8008/_matrix
</VirtualHost> </VirtualHost>
<VirtualHost *:8448> <VirtualHost *:8448>
SSLEngine on SSLEngine on
ServerName example.com; ServerName example.com;
AllowEncodedSlashes NoDecode AllowEncodedSlashes NoDecode
ProxyPass /_matrix http://127.0.0.1:8008/_matrix nocanon ProxyPass /_matrix http://127.0.0.1:8008/_matrix nocanon
ProxyPassReverse /_matrix http://127.0.0.1:8008/_matrix ProxyPassReverse /_matrix http://127.0.0.1:8008/_matrix
</VirtualHost> </VirtualHost>
```
> **NOTE**: ensure the `nocanon` options are included. **NOTE**: ensure the `nocanon` options are included.
### HAProxy ### HAProxy
frontend https ```
frontend https
bind :::443 v4v6 ssl crt /etc/ssl/haproxy/ strict-sni alpn h2,http/1.1 bind :::443 v4v6 ssl crt /etc/ssl/haproxy/ strict-sni alpn h2,http/1.1
# Matrix client traffic # Matrix client traffic
@ -119,12 +128,13 @@ canonicalise/normalise the URI.
use_backend matrix if matrix-host matrix-path use_backend matrix if matrix-host matrix-path
frontend matrix-federation frontend matrix-federation
bind :::8448 v4v6 ssl crt /etc/ssl/haproxy/synapse.pem alpn h2,http/1.1 bind :::8448 v4v6 ssl crt /etc/ssl/haproxy/synapse.pem alpn h2,http/1.1
default_backend matrix default_backend matrix
backend matrix backend matrix
server matrix 127.0.0.1:8008 server matrix 127.0.0.1:8008
```
## Homeserver Configuration ## Homeserver Configuration