You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
www/caddy: Add a few more details to docs (opnsense#569)
* www/caddy: Add section about interface binding, Add note about OPNsense WebGUI not always listening on 127.0.0.1 when reverse proxying it.
* Explain new subdomain port behavior, explain handler behavior better - the logic was there since the beginning but got lost in the docs.
* Add note about cookie security.
* Add hint about syncookies, make Creating a Simple Reverse Proxy clearer, add hint for HTTP-01 challenge redirection not needing a handler.
Copy file name to clipboardExpand all lines: source/manual/how-tos/caddy.rst
+46-6Lines changed: 46 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,8 @@ Option Values
79
79
80
80
Go to :menuselection:`Firewall --> Rules --> LAN` and create the same rules for the `LAN` interface. Now external and internal clients can connect to Caddy, and `Let's Encrypt` or `ZeroSSL` certificates will be issued automatically.
81
81
82
+
.. Note:: Caddy upgrades all connections automatically from HTTP to HTTPS. When cookies do not have have the ``secure`` flag set by the application serving them, they can still be transmitted unencrypted before the connection is upgraded. If these cookies contain very sensitive information, it might be a good choice to close port 80.
83
+
82
84
83
85
---
84
86
FAQ
@@ -103,6 +105,7 @@ Caddy: Tutorials
103
105
104
106
.. Attention:: The tutorial section implies that :ref:`Prepare OPNsense for Caddy after installation <prepare-opnsense-caddy>` has been followed.
105
107
.. Note:: Filling out `Description` fields is mandatory because they are used to display and reference items in forms and error messages.
108
+
.. Tip:: Handlers are not limited to one per domain/subdomain. If there are multiple different URIs to handle (e.g. ``/foo/*`` and ``/bar/*``), create a handler for each of them. Just make sure each of these URIs are on the same level, creating ``/foo/*`` and ``/foo/bar/*`` will make ``/foo/*`` match everything. Additionally, when creating an empty handler for a domain/subdomain, the templating logic will always automatically place it last in the Caddyfile site block. This means, specific URIs will always match before an empty URI. Though, using just one handler with an empty URI is recommended for most usecases, since it catches all traffic directed at a domain/subdomain.
106
109
107
110
108
111
-------------------------------
@@ -119,7 +122,7 @@ Go to :menuselection:`Services --> Caddy Web Server --> General Settings`
119
122
120
123
Go to :menuselection:`Services --> Caddy Web Server --> Reverse Proxy --> Domains`
121
124
122
-
* Press **+** to create a new `Domain`, this will be the frontend that receives the traffic for the chosen domain name.
125
+
* Press **+** to create a new `Domain`, this will be the frontend that receives the traffic for the chosen domain name. The OPNsense listens for this domain on all interfaces.
Go to :menuselection:`Services --> Caddy Web Server --> Reverse Proxy --> Handler`
135
138
136
-
* Press **+** to create a new `Handler`, this will route the traffic from the frontend domain to the upstream destination.
139
+
* Press **+** to create a new `Handler`, this will route the traffic from the frontend domain to the upstream destination. The upstream is an internal service that should receive the reverse proxied traffic from the OPNsense.
@@ -289,6 +292,8 @@ Create a Wildcard Reverse Proxy with DNS-01 Challenge
289
292
290
293
.. Attention:: The certificate of a wildcard domain will only contain ``*.example.com``, not a SAN for ``example.com``. Create an additional domain for ``example.com`` with an additional handler for its upstream destination.
291
294
295
+
.. Note:: Subdomains do not support setting ports, they will always track the ports of their assigned parent wildcard domain.
296
+
292
297
Go to :menuselection:`Services --> Caddy Web Server --> General Settings --> DNS Provider`
293
298
294
299
* Select one of the supported `DNS Providers` from the list
@@ -313,6 +318,8 @@ Reverse Proxy the OPNsense WebGUI
313
318
---------------------------------
314
319
315
320
.. Tip:: The same approach can be used for any upstream destination using TLS and a self-signed certificate.
321
+
.. Attention:: The OPNsense WebGUI is only bound to 127.0.0.1 when no specific interface is selected: :menuselection:`System --> Settings --> Administration` - `Listen Interfaces - All (recommended)`. Otherwise, use the IP address of the specific interface as "Upstream Domain".
322
+
.. Attention:: When setting `Enable syncookies` to `always` in :menuselection:`Firewall --> Settings --> Advanced`, reverse proxying the WebGUI is currently not possible. Set it to an `adaptive` setting, or `never (default)`.
316
323
317
324
* | Open the OPNsense WebGUI in a browser (e.g. Chrome or Firefox). Inspect the certificate by clicking on the 🔒 in the address bar. Copy the SAN for later use. It can be a hostname, for example ``OPNsense.localdomain``.
318
325
* | Save the certificate as ``.pem`` file. Open it up with a text editor, and copy the contents into a new entry in :menuselection:`System --> Trust --> Authorities`. Name the certificate ``opnsense-selfsigned``.
.. Note:: The `HTTP-01 Challenge Redirection` already works now and the internal resource located at ``192.168.10.1`` will be able to issue the certificate for the domain name ``foo.example.com``. If the internal ressource should also be reverse proxied, add a handler to the domain.
366
375
367
376
Go to :menuselection:`Services --> Caddy Web Server --> Reverse Proxy --> Handler`
368
377
@@ -509,9 +518,40 @@ Having a large configuration can become a bit cumbersome to navigate. To help, a
509
518
.. Tip:: In `Filter by Domain`, one or multiple `Domains` can be selected, and as filter result, only their corresponding configuration will be displayed in `Domains`, `Subdomains` and `Handlers`. This makes keeping track of large configurations a breeze.
510
519
511
520
512
-
------------------------
513
-
Advanced Troubleshooting
514
-
------------------------
521
+
------------------------------------------
522
+
Advanced: Bind Caddy to specific Interface
523
+
------------------------------------------
524
+
525
+
.. Warning:: Binding a service to a specific interface via IP address can cause lots of issues. If the IP address is dynamic, the service can crash or refuse to start. During boot, the service can refuse to start if the interface IP addresses are assigned too late. Configuration changes on the interfaces can cause the service to crash. **Only use this with static IP addresses! There is no OPNsense community support for this configuration.**
526
+
527
+
.. Note:: This configuration is only useful if there are two or more WAN interfaces, and Caddy should only respond on one of them. It can also solve port conflicts, for example if one interface should DNAT or host a different service with the default webserver ports. **In all other cases, it is always better not to do this.**
528
+
529
+
* Create the following files with the following content in the OPNsense filesystem:
0 commit comments