diff --git a/docs/cloudflare-tunnel.md b/docs/cloudflare-tunnel.md index ef6d789..f41680e 100644 --- a/docs/cloudflare-tunnel.md +++ b/docs/cloudflare-tunnel.md @@ -2,39 +2,50 @@ Your server is on a local network, and you want to expose it on the internet (clearnet)? -While there is many solutions at your disposal, this one is by far the less costly and easiest. +While there are many solutions at your disposal, this one is by far the least costly and easiest. Traditionally, the solution to this problem is either: -* Configure correctly your firewall and your internet router (NAT) to accept incoming traffic +* Configure your firewall and your internet router (NAT) correctly to accept incoming traffic * Use Tor -* Setup a SSH reverse tunnel to a public VPS +* Setup an SSH reverse tunnel to a public VPS -The challenge with the first solution si that there is no unified way to do it. Every local network have their own way to do. -On top of it, it may not even work: internet server providers may block incoming traffic, or they might use dynamic IPs, meaning you need to setup a [dyndns service](https://docs.btcpayserver.org/Deployment/DynamicDNS/) to update the DNS record automatically when the IP change. +The challenge with the first solution is that there is no unified way to do it. Every local network has its own way of doing. +On top of it, it may not even work: internet server providers may block incoming traffic, or they might use dynamic IPs. You need to set up a [dyndns service](https://docs.btcpayserver.org/Deployment/DynamicDNS/) to update the DNS record when the IP changes automatically. -The challenges with the second solution are that Tor has very high latency, so your server will feel sluggish and unreliable and you would need a Tor enabled browser to access it. (such as Brave or Tor Browser) +The challenges with the second solution are that Tor has very high latency, so your server will feel sluggish and unreliable, and you would need a Tor-enabled browser to access it. (such as Brave or Tor Browser) The third solution is technically challenging and isn't free, as you need to pay for a VPS. -Cloudflare tunnel offer an alternative to those solutions with a single downside: Cloudflare is able to see or modify all of your traffic, as it acts as a middleman between the client's browser and your local server. +Cloudflare tunnel offers an alternative to those solutions with a single downside: Cloudflare can see or modify all of your traffic, as it acts as a middleman between the client's browser and your local server. -With cloudflare tunnel, you will enjoy low latency access to your server, on clearnet and WITHOUT the need to configure your firewall, internet router, dynamic dns and on any internet service provider. For free. +With Cloudflare tunnel, you will enjoy low latency access to your server, on clearnet, and WITHOUT the need to configure your firewall, internet router, dynamic DNS, and any internet service provider. For free. -You still need to configure the tunnel correctly, and this documentation will guide you through it. +You still need to configure the tunnel correctly; this documentation will guide you through it. ## How to use? -First we are going to create the tunnel on Cloudflare. +First, we are going to create the tunnel on Cloudflare. 1. You need to [create an account on Cloudflare](https://cloudflare.com/). -2. Enable Cloudflare for your domain name. For namecheap, [follow this tutorial](https://www.namecheap.com/support/knowledgebase/article.aspx/9607/2210/how-to-set-up-dns-records-for-your-domain-in-cloudflare-account/). +2. Enable Cloudflare for your domain name. For Namecheap, [follow this tutorial](https://www.namecheap.com/support/knowledgebase/article.aspx/9607/2210/how-to-set-up-dns-records-for-your-domain-in-cloudflare-account/). 3. After the DNS changes are propagated, go to [Zero Trust](https://dash.teams.cloudflare.com/) option on the left menu, go to `access`, then click `tunnels`. -4. Click `create tunnel` button, give it a name -5. In `Choose your environment`, click on docker and copy your token, you will need it later (the string after `--token`, as shown in the following screenshot) -![](./img/Cloudflare-Tunnel-Token.png) + +![BTCPay Server Cloudflare Tunnel](./img/btcpayexposecloudflare1.jpg) + +4. Click the `create tunnel` button, and give it a name + +![BTCPay Server Cloudflare Tunnel](./img/btcpayexposecloudflare2.jpg) + +5. In `Choose your environment`, click on docker and copy your token. You will need it later (the string after `--token`, as shown in the following screenshot) + +![BTCpay Server Cloudflare Tunnel](./img/Cloudflare-Tunnel-Token.png) + 6. Click on the `Next` button -7. Enter your subdomain, select your domain in the list. Then in `Service` select `HTTP` and enter `nginx`. -8. In your the SSH session of your server, add cloudflare tunnel by running the following script. (replace `` by what you copied in step `5.`, and also replace `` with the domain you entered in steps `7.`) +7. Enter your subdomain, and select your domain in the list. Then in `Service` select `HTTP` and enter `nginx`. + +![BTCPay Server Cloudflare Tunnel](./img/btcpayexposecloudflare5.jpg) + +8. In the SSH section of your server, add Cloudflare tunnel by running the following script. (replace `` with what you copied in step `5.`, and also replace `` with the domain you entered in steps `7.`) ```bash BTCPAY_HOST="" [[ "$REVERSEPROXY_DEFAULT_HOST" ]] && REVERSEPROXY_DEFAULT_HOST="$BTCPAY_HOST" @@ -44,20 +55,20 @@ BTCPAYGEN_EXCLUDE_FRAGMENTS="$BTCPAYGEN_EXCLUDE_FRAGMENTS;nginx-https" . btcpay-setup.sh -i ``` -Now you should be able to access your server from internet! (If you get an nginx error 503, check below) +Now you should be able to access your server from the internet! (If you get an Nginx error 503, check below) ## Recommended additional step -In [cloudflare dashboard](https://dash.cloudflare.com), navigate to your websites, go to `Edge Certificates` and check `Always Use HTTPS`. This will make sure that any request to your website use HTTPS. +In [cloudflare dashboard](https://dash.cloudflare.com), navigate to your websites, go to `Edge Certificates`, and check `Always Use HTTPS`. This will make sure that any request to your website uses HTTPS. ![](./img/Cloudflare-Always-Https.png) ## Known error ### Error 503 -An error 503 means that the tunnel is working and cloudflare correctly set up, the HTTP request is reaching your server, but the server's reverse proxy doesn't know which downstream container should receive the request. +An error 503 means that the tunnel is working and Cloudflare is correctly set up, the HTTP request is reaching your server, but the server's reverse proxy doesn't know which downstream container should receive the request. -This command will instruct to forward any requests from your domain to your BTCPay Server container. It also instructs to forward any HTTP requests with an unrecognized domain name to your BTCPay Server container. +This command will instruct you to forward any requests from your domain to your BTCPay Server container. It also instructs you to forward any HTTP requests with an unrecognized domain name to your BTCPay Server container. ```bash BTCPAY_HOST="" @@ -65,4 +76,4 @@ REVERSEPROXY_DEFAULT_HOST="" . btcpay-setup.sh -i ``` -`REVERSEPROXY_DEFAULT_HOST` will make sure that you can still access your server from the local network with an ip or a local domain name. +`REVERSEPROXY_DEFAULT_HOST` will ensure you can still access your server from the local network with an IP or a local domain name. diff --git a/docs/img/btcpayexposecloudflare1.jpg b/docs/img/btcpayexposecloudflare1.jpg new file mode 100644 index 0000000..995c1aa Binary files /dev/null and b/docs/img/btcpayexposecloudflare1.jpg differ diff --git a/docs/img/btcpayexposecloudflare2.jpg b/docs/img/btcpayexposecloudflare2.jpg new file mode 100644 index 0000000..a024e94 Binary files /dev/null and b/docs/img/btcpayexposecloudflare2.jpg differ diff --git a/docs/img/btcpayexposecloudflare3.jpg b/docs/img/btcpayexposecloudflare3.jpg new file mode 100644 index 0000000..49c6bac Binary files /dev/null and b/docs/img/btcpayexposecloudflare3.jpg differ diff --git a/docs/img/btcpayexposecloudflare4.jpg b/docs/img/btcpayexposecloudflare4.jpg new file mode 100644 index 0000000..814d6d0 Binary files /dev/null and b/docs/img/btcpayexposecloudflare4.jpg differ diff --git a/docs/img/btcpayexposecloudflare5.jpg b/docs/img/btcpayexposecloudflare5.jpg new file mode 100644 index 0000000..1106208 Binary files /dev/null and b/docs/img/btcpayexposecloudflare5.jpg differ diff --git a/docs/img/cloudflarexpose.png b/docs/img/cloudflarexpose.png new file mode 100644 index 0000000..d3a1895 Binary files /dev/null and b/docs/img/cloudflarexpose.png differ