From 53baad11c388efaab7690d94976bc7d52e37297a Mon Sep 17 00:00:00 2001 From: 9pfs <9pfs@amcforum.wiki> Date: Wed, 20 Nov 2024 15:31:57 -0800 Subject: [PATCH] Add nginx site-level templates --- .gitignore | 1 + nginx-html.j2 | 2 ++ nginx-site.j2 | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 .gitignore create mode 100644 nginx-html.j2 create mode 100644 nginx-site.j2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/nginx-html.j2 b/nginx-html.j2 new file mode 100644 index 0000000..9069bf2 --- /dev/null +++ b/nginx-html.j2 @@ -0,0 +1,2 @@ +default_type text/html; +return 200 'myip.dn42
your IP address$remote_addr
this node\'s IP address$server_addr
this node\'s ASN4242422002
this node\'s country{% if country is defined %}{{ country }}{% else %}US{% endif %}
this node\'s name{% if fqdn is defined %}{{ fqdn }}{% else %}myip.9pfs.dn42{% endif %}
'; diff --git a/nginx-site.j2 b/nginx-site.j2 new file mode 100644 index 0000000..b7fbc81 --- /dev/null +++ b/nginx-site.j2 @@ -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' %} + } +}