diff --git a/README.md b/README.md new file mode 100644 index 0000000..13c8c5e --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# This Computer + +Shows your IP address(es). Powered by a single static file and a Nginx config. + +Available at [this.computer](https://this.computer). + +## Make your own + +* Install Nginx, Certbot and Node.js (for the "build script"). +* Have a hostname for the website. +* Have two hostnames for the IP checks, one with just an A record, one with just AAAA. + +Do this (substitute the hostnames): + +```bash + +# substitute the hostnames. $PWD/dist is where the html file is +node build.js this.computer 4.this.computer 6.this.computer $PWD/dist + +# LetsEncrypt setup (skip and edit the main config if you prefer handling it yourself) + +# If target does not exist, try /etc/nginx/sites or /etc/nginx/conf.d +sudo mkdir -p /srv/tmp +sudo cp conf/this-computer-certbot.conf /etc/nginx/sites-enabled +sudo systemctl reload nginx +sudo certbot certonly --webroot -w /srv/tmp -d this.computer -d 4.this.computer -d 6.this.computer +# Assuming the above worked! +echo 'systemctl reload nginx' | sudo tee /etc/letsencrypt/renewal-hooks/deploy/nginx.sh +sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/nginx.sh + +# After certificates are ready: +sudo cp conf/this-computer.conf /etc/nginx/sites-enabled +sudo systemctl reload nginx + +``` + +## License + +MIT \ No newline at end of file diff --git a/template/this-computer-certbot.conf b/template/this-computer-certbot.conf index 279c948..c12f19e 100644 --- a/template/this-computer-certbot.conf +++ b/template/this-computer-certbot.conf @@ -1,7 +1,10 @@ server { listen 80; server_name BASE_HOST IP4_HOST IP6_HOST; - location /.well-known { - root /srv/tmp; - } + location /.well-known { + root /srv/tmp; + } + location / { + rewrite . https://BASE_HOST$uri; + } } diff --git a/template/this-computer.conf b/template/this-computer.conf index 391c1f6..80bc979 100644 --- a/template/this-computer.conf +++ b/template/this-computer.conf @@ -7,15 +7,15 @@ server { listen 443 ssl http2; server_name BASE_HOST; - #ssl_certificate /etc/letsencrypt/live/BASE_HOST/fullchain.pem; - #ssl_certificate_key /etc/letsencrypt/live/BASE_HOST/privkey.pem; + ssl_certificate /etc/letsencrypt/live/BASE_HOST/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/BASE_HOST/privkey.pem; - root DIST_DIR; + root DIST_DIR; location = / { rewrite . $respond_with; } location /text { - add_header Cache-Control "no-cache"; + add_header Cache-Control "no-cache"; return 200 "$remote_addr\n\nSee also:\nhttps://IP4_HOST\nhttps://IP6_HOST\n"; } location / { @@ -30,8 +30,8 @@ server { listen 443 ssl http2; server_name IP4_HOST IP6_HOST; - #ssl_certificate /etc/letsencrypt/live/BASE_HOST/fullchain.pem; - #ssl_certificate_key /etc/letsencrypt/live/BASE_HOST/privkey.pem; + ssl_certificate /etc/letsencrypt/live/BASE_HOST/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/BASE_HOST/privkey.pem; location / { add_header Content-Type text/plain;