Showing posts from August, 2021

Turning a Git Repository into a Simple File Host with Cloudflare Workers

Recently I used Cloudflare Workers for the first time to create the website you're reading right now (look at Fruition to learn how I did it), and I decided to try out writing some of my own workers to get an idea of what it could do. I was in need of a simple static file host to serve various small files - stuff like HTML, presentations, PDFs etc - and thought about how Git repository hosts generally allow you to view a file within a repository in its raw format, served directly to you without modifications. I figured that I could use a Cloudflare Worker to proxy a request to a raw file path on my Git hosting service, and rewrite any necessary headers to ensure that files are served to browsers correctly. Here's how I did it: If you do not already have an account, sign up at CloudFlare and follow the step-by-step instructions provided to set up your domain to use their services. Click the workers button at the top of the page Set up your worker subdomain - this can

Simple Wireguard VPN Setup

First, install Wireguard. For Ubuntu: sudo apt install wireguard If you want to forward all traffic from clients, enable IP forwarding in the kernel. Next, create a config file at /etc/wireguard/wg0.conf containing the following (you can also choose to allocate v6 addresses to clients): [Interface] PrivateKey = <server_private_key_goes_here> Address = 172.16 . 1.1 / 32 ListenPort = 51820 # Use the following for forwarding all traffic from clients: # Change eth0 to your network interface if it differs PostUp = iptables -A FORWARD -i wg0 -j ACCEPT ; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; iptables -A INPUT -s -p tcp -m tcp --dport 53 -m conntrack --ctstate NEW -j ACCEPT; iptables -A INPUT -s -p udp -m udp --dport 53 -m conntrack --ctstate NEW -j ACCEPT PostDown = iptables -D FORWARD -i wg0 -j ACCEPT ; iptables -t nat -D POSTROUTING -