Skip to content

Commit

Permalink
Readme, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
virtulis committed Dec 19, 2023
1 parent fb85454 commit 92abf2e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions template/this-computer-certbot.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
12 changes: 6 additions & 6 deletions template/this-computer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 / {
Expand All @@ -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;
Expand Down

0 comments on commit 92abf2e

Please sign in to comment.