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
Thank you for your response, I just need to convert this code to UFW
iptables -t nat -A PREROUTING -s $i -p tcp --dport 443 -j DNAT --to-destination $1:443;
can you help me, please?
also, I will check Tailscale, but I"m providing VPN in restricted countries and main IP of my server will be block less than 1 hour, the only thing I can do is hiding real IP, if you help me I will so much appreciate it
thanks a lot