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
$serveripOpenVPN server on port 4443 - Setup VM's running on
$destinationipto connect to$serveripOpenVPN (ideally using pfsense with killswitch). This should prevent accidental IP disclosure. - Setup
$destinationipport80/443forwarding to nginx-proxy-manager, only allow from$serverip - Setup
$destinationipnginx-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
$managmentipto access SSH port on$serverip - Blocks all web (80/443) traffic on
$serverip - Forwards all web traffic (80/443) on on
$serveripto$destinationiponly if received from cloudflare - Whitelist
$destinationipto access OpenVPN on$serverip
I'm not sure my hackey script is really the best thing to be emulating...
This might help you with the port forwarding from one IP to another using UFW: https://www.cyberciti.biz/faq/how-to-configure-ufw-to-forward-port-80443-to-internal-server-hosted-on-lan/
Also if you haven't heard of fly.io, based on the limited info I have about what you're working on I think it might be useful for some of your project's infrastructure.