|
| 1 | +--- |
| 2 | +title: Accessing WLED over Internet |
| 3 | +hide: |
| 4 | + # - navigation |
| 5 | + # - toc |
| 6 | +--- |
| 7 | + |
| 8 | +WLED exposed to Internet safely with the help of a reverse proxy setup. |
| 9 | +This document describes the steps needed. |
| 10 | + |
| 11 | +!!! warning "Port Forwarding" |
| 12 | + Under no circumstances port forward WLED instance to the public internet. |
| 13 | + WLED does not support HTTPS or authentication, leading to a fundamentally insecure setup. |
| 14 | + |
| 15 | +!!! tip "Consider VPN Tunneling" |
| 16 | + If you only need access from a single device, such as your phone, |
| 17 | + consider a point-to-point VPN tunnel instead. Configuring a tunnel |
| 18 | + may require less configuration and maintenance than a HTTPS reverse proxy. |
| 19 | + |
| 20 | +# Reverse proxy requirements |
| 21 | + |
| 22 | +WLED does not implement access control, allowing anyone able to connect to it change configuration or even update firmware. |
| 23 | +For a safe access, **the reverse proxy MUST implement access control** to only allow trusted users to access WLED. |
| 24 | + |
| 25 | +Secure access control cannot be implemented over insecure connection. **The reverse proxy MUST implement TLS termination**, only allowing access over HTTPS. |
| 26 | + |
| 27 | +Reverse proxy cannot run on the WLED device. |
| 28 | +You need a server in your local network to perform the encryption and proxying. |
| 29 | + |
| 30 | +# Example |
| 31 | + |
| 32 | +Assuming the following network setup, using Caddy as a reverse proxy: |
| 33 | + |
| 34 | +``` |
| 35 | +[Public Internet] |
| 36 | + | |
| 37 | +[Router] |
| 38 | + | |
| 39 | +[Reverse Proxy] |
| 40 | + | |
| 41 | +[WLED] |
| 42 | +``` |
| 43 | + |
| 44 | +First, register a domain name. In this example, we assume the name "mydomain.example". |
| 45 | +A domain name is commonly a requirement for a HTTP certificate. |
| 46 | +You can use a dynamic dns provider for a free domain. |
| 47 | + |
| 48 | +Next, generate a HTTPs certificate for your domain. |
| 49 | +For the free Let's Encrypt certificates, configure necessary the automation for refreshing the certificate automatically. |
| 50 | +In this example, we are using Caddy which handles this automatically. |
| 51 | + |
| 52 | +We then expose the HTTPS port of the reverse proxy to public internet. |
| 53 | +In your network router, port forward port TCP 443 into the Reverse Proxy. |
| 54 | +In this example, we are using Caddy which only requires port 443 to complete the Let's Encrypt challenge for automatic certificate issuing. |
| 55 | +With other software, you may need to also open insecure HTTP port 80. |
| 56 | + |
| 57 | +Finally, in Caddyfile, configure the reverse proxy and authentication |
| 58 | +Note that Caddy uses HTTPS by default. |
| 59 | +With other software, we may need to disable access over the unsafe HTTP. |
| 60 | + |
| 61 | +``` |
| 62 | +mydomain.example { |
| 63 | + handle /wled/* { |
| 64 | + # Create username and password. Password can be with `caddy hash-password --plaintext mypass` |
| 65 | + basicauth { |
| 66 | + yourusername PASSWORDHASH |
| 67 | + } |
| 68 | + uri strip_prefix /wled |
| 69 | + reverse_proxy wled-wled-a.lan # IP address or the network local name of the WLED device |
| 70 | + } |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +Now `https://mydomain.example/wled/` exposes WLED to the public internet using secure HTTPS and password authentication. |
| 75 | + |
| 76 | +For additional securty, consider enabling [OTA lock password](/advanced/ota-lock). |
0 commit comments