Add nginx site-level templates

This commit is contained in:
9pfs 2024-11-20 15:31:57 -08:00
commit 53baad11c3
Signed by: 9pfs
SSH key fingerprint: SHA256:yVO09iotyiNaBzBBvVR8ZTx7SB9VpvJPgR1Ihy1bz3Q
3 changed files with 28 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.swp

2
nginx-html.j2 Normal file
View file

@ -0,0 +1,2 @@
default_type text/html;
return 200 '<!DOCTYPE html><html lang="en"><head><title>myip.dn42</title><meta name="author" content="dn42 community"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="robots" content="index, follow"><meta name="description" content="This service can tell you your IP address in dn42."><meta name="keywords" content="what is my ip,my ip"><body><table><tr><th>your IP address</th><td>$remote_addr</td></tr><tr><th>this node\'s IP address</th><td>$server_addr</td></tr><tr><th>this node\'s ASN</th><td>4242422002</td></tr><tr><th>this node\'s country</th><td>{% if country is defined %}{{ country }}{% else %}US{% endif %}</td></tr><tr><th>this node\'s name</th><td>{% if fqdn is defined %}{{ fqdn }}{% else %}myip.9pfs.dn42{% endif %}</td></tr></table></body></html>';

25
nginx-site.j2 Normal file
View file

@ -0,0 +1,25 @@
server {
listen [fd32:6b0:70a6:8181::81]:80;
{% if unicastv6 is defined %}
listen [{{ unicastv6 }}]:80;
{% endif %}
server_name myip.9pfs.dn42;
server_name *.myip.9pfs.dn42;
server_name [fd32:6b0:70a6:8181::81];
{% if unicastv6 is defined %}
listen [{{ unicastv6 }}];
location = /raw {
return 200 '$remote_addr\n';
default_type text/plain;
}
location = /api {
default_type application/json;
add_header 'Access-Control-Allow-Origin' '*';
return 200 '{\n\t"version": "1.0",\n\t"ip": "$remote_addr",\n\t"server": "$server_addr",\n\t"node_as": "4242422002",\n\t"node_location": "{% if country is defined %}{{ country }}{% else %}US{% endif %},\n\t"node_id": "{% if fqdn is defined %}{{ fqdn }}{% else %}myip.9pfs.dn42{% endif %}"\n}';
}
location = / {
{% include 'nginx-html.j2' %}
}
}