From 97e7a0fa07accfe9b93de9f4665aedb1d91703f0 Mon Sep 17 00:00:00 2001 From: Jacobite89 <52151591+Jacobite89@users.noreply.github.com> Date: Fri, 17 Jan 2020 13:01:44 +0100 Subject: [PATCH] Add Caddy v2 example --- Proxy-examples.md | 56 +++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/Proxy-examples.md b/Proxy-examples.md index 43bca6c..e1e3ec7 100644 --- a/Proxy-examples.md +++ b/Proxy-examples.md @@ -4,29 +4,47 @@ The ports proxied by default are `80` for the web server and `3012` for the WebS When using a proxy, it's preferrable to configure HTTPS at the proxy level and not at the application level, this way the WebSockets connection is also secured. ## Caddy - +Caddy can also automatically enable HTTPS in some circumstances, check the [docs](https://caddyserver.com/v1/docs/automatic-https). ```nginx -localhost:443 { - # The negotiation endpoint is also proxied to Rocket - proxy /notifications/hub/negotiate :80 { - transparent - } - - # Notifications redirected to the websockets server - proxy /notifications/hub :3012 { - websocket - } - - # Proxy the Root directory to Rocket - proxy / :80 { - transparent - } +:443 { + tls ${SSLCERTIFICATE} ${SSLKEY} + # or 'tls self_signed' to generate a self-signed certificate + gzip - tls ${SSLCERTIFICATE} ${SSLKEY} - # or 'tls self_signed' to generate a self-signed certificate + # The negotiation endpoint is also proxied to Rocket + proxy /notifications/hub/negotiate :80 { + transparent + } + + # Notifications redirected to the websockets server + proxy /notifications/hub :3012 { + websocket + } + + # Proxy the Root directory to Rocket + proxy / :80 { + transparent + } +} +``` + +## Caddy v2 +Caddy v2 can also automatically enable HTTPS in some circumstances, check the [docs](https://caddyserver.com/docs/automatic-https). +```nginx +:443 { + tls ${SSLCERTIFICATE} ${SSLKEY} + encode gzip + + # The negotiation endpoint is also proxied to Rocket + reverse_proxy /notifications/hub/negotiate :80 + + # Notifications redirected to the websockets server + reverse_proxy /notifications/hub :3012 + + # Proxy the Root directory to Rocket + reverse_proxy / :80 } ``` -Caddy can also automatically enable HTTPS in some circumstances, check the [docs](https://caddyserver.com/docs/automatic-https). ## Nginx (by shauder) ```nginx