Helps facilitate the ability to run internet facing web apps on a homelab ($desinationip
) without exposing the homelab's IP address and forcing the use of CloudFlare for incoming traffic. Tunnels both incoming web traffic and outgoing traffic. Uses public cloud VPS ($serverip
) as the reverse proxy and VPN.
This setup should hide the homelab's IP even in the event of compromise, end-to-end encrypt all web traffic between CloudFlare and the homelab, and prevents the proxy server from being accessed directly.
Internet --> Cloudflare (80/443) --> Cloud Provider (cloudflare-reverse-proxy.sh) --> Homelab (port forward + nginx-proxy-manager)
Homelab (all traffic) --> Cloud Provider (OpenVPN on 4443) --> Internet
- If Homelab's IP is discovered, it will only accept traffic from the proxy server, directed at a specific domain, and that traffic will only hit the web apps if it is properly encrypted from CloudFlare.
- If the proxy's IP is discovered, it will only accept incoming connections from HomeLab's IP on port 4443 and a managment IP on port 22. Additonally traffic sent to 80/443 will only be forwarded to the homelab if it's from CloudFlare.
- If the Homelab web app is pwnd, all outbound connections will be forced through the proxy, hiding the homelab's location.
- Setup
$serverip
OpenVPN server on port 4443 - Setup VM's running on
$destinationip
to connect to$serverip
OpenVPN (ideally using pfsense with killswitch). This should prevent accidental IP disclosure. - Setup
$destinationip
port80/443
forwarding to nginx-proxy-manager, only allow from$serverip
- Setup
$destinationip
nginx-proxy-manager domains and only allow access from$serverip
, import Cloudflare SSL origin certs. - Setup cloudflare domains and point to
$serverip
, enable proxying and "Full Strict SSL". - Run the script
wget https://gist.githubusercontent.com/GlitchWitch/207d18c8902fcb5e1c5f0e043f8e9101/raw/862bf56e2fe02e09f3dec22a218824990bb18079/cloudflare-reverse-proxy.sh && bash cloudflare-reverse-proxy.sh desinationip managmentip && rm cloudflare-reverse-proxy.sh
- Blocks all incoming SSH traffic on
$serverip
- Whitelists
$managmentip
to access SSH port on$serverip
- Blocks all web (80/443) traffic on
$serverip
- Forwards all web traffic (80/443) on on
$serverip
to$destinationip
only if received from cloudflare - Whitelist
$destinationip
to access OpenVPN on$serverip
Hi Dear, I want to use your .sh for ocserv in Ubuntu 23.10, but your iptables code not working and get error, bad argument, my interface is ens34, also, in Ubuntu 23.10 only UFW working, please tell me how can I convert your iptables code to UFW code to working well?
if you help me so many regards and thanks to you, it's too important, because ocserv with Cloudflare asking username and password, but not connecting, maybe with your script my probblem will be solve