diff --git a/ipapi/cm-template.yaml b/ipapi/cm-template.yaml new file mode 100644 index 0000000..e8d9ae8 --- /dev/null +++ b/ipapi/cm-template.yaml @@ -0,0 +1,169 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: html-template +data: + index.html: | + + + + + What is my IP address? — {{ .Host }} + + + + + + + + +
+
+

What is my IP address?

+

{{ .IP }}

+
+
+
+
+ {{ if .Country }} +

Country lookup

+
+    $ http {{ .Host }}/country
+    {{ .Country }}
+
+    $ http {{ .Host }}/country-iso
+    {{ .CountryISO }}
+ {{ end }} + {{ if .City }} +

City lookup

+
+    $ http {{ .Host }}/city
+    {{ .City }}
+ {{ end }} + {{ if .ASN }} +

ASN lookup

+
+    $ http {{ .Host }}/asn
+    {{ .ASN }}
+    {{ if .ASNOrg }}
+

Looks like you're with {{ .ASNOrg }}

+ {{ end }} + {{ end }} +
+
+

JSON output

+
+    $ http {{ .Host }}/json
+    {{ .JSON }}
+ {{ if .Port }} +

All endpoints

+
+            {{ .Host }}
+            {{ .Host }}/ip
+            {{ .Host }}/json
+            {{ .Host }}/country
+            {{ .Host }}/country-iso
+            {{ .Host }}/city
+            {{ .Host }}/asn
+            {{ .Host }}/coordinates
+            {{ .Host }}/port/$number
+            
+ {{ end }} +
+ {{ if .City }} +
+

Map

+ +
+ {{ end }} +
+

FAQ

+

Why is IPv6 not supported?

+

This service runs on k3s which currently doesn't support IPv6. + see: +

+

+
+
+ + {{ if or .Country .City .ASN .ASNOrg }} +
+ +
+ {{ end }} + + diff --git a/ipapi/deployment.yaml b/ipapi/deployment.yaml index dcbdb39..94b7247 100644 --- a/ipapi/deployment.yaml +++ b/ipapi/deployment.yaml @@ -40,6 +40,8 @@ spec: - -p - -C - "1000" + - -t + - /data/template/index.html ports: - containerPort: 8080 name: http @@ -47,6 +49,8 @@ spec: volumeMounts: - name: geoip mountPath: /data/geoip + - name: template + mountPath: /data/template livenessProbe: httpGet: path: /health @@ -62,10 +66,16 @@ spec: limits: memory: 256Mi cpu: 300m + securityContext: + runAsUser: 1000 + runAsGroup: 1000 volumes: - name: geoip persistentVolumeClaim: claimName: ipapi-geodb + - name: template + configMap: + name: html-template dnsPolicy: ClusterFirst restartPolicy: Always securityContext: {} diff --git a/ipapi/index.html b/ipapi/index.html new file mode 100644 index 0000000..0e82496 --- /dev/null +++ b/ipapi/index.html @@ -0,0 +1,195 @@ + + + + + What is my IP address? — {{ .Host }} + + + + + + + + +
+
+

What is my IP address?

+

{{ .IP }}

+

Multiple command line HTTP clients are supported, + including curl, httpie, GNU + Wget + and fetch.

+
+
+
+
+

CLI examples

+
+$ curl {{ .Host }}
+{{ .IP }}
+
+$ http -b {{ .Host }}
+{{ .IP }}
+
+$ wget -qO- {{ .Host }}
+{{ .IP }}
+
+$ fetch -qo- https://{{ .Host }}
+{{ .IP }}
+
+$ bat -print=b {{ .Host }}/ip
+{{ .IP }}
+{{ if .Country }} +

Country lookup

+
+$ http {{ .Host }}/country
+{{ .Country }}
+
+$ http {{ .Host }}/country-iso
+{{ .CountryISO }}
+{{ end }} +{{ if .City }} +

City lookup

+
+$ http {{ .Host }}/city
+{{ .City }}
+{{ end }} +{{ if .ASN }} +

ASN lookup

+
+$ http {{ .Host }}/asn
+{{ .ASN }}
+{{ if .ASNOrg }}
+

Looks like you're with {{ .ASNOrg }}

+{{ end }} +{{ end }} +
+
+

JSON output

+
+$ http {{ .Host }}/json
+{{ .JSON }}
+

Setting the Accept: application/json header also works as expected.

+

Plain output

+

Always returns the IP address including a trailing newline, regardless of user agent.

+
+$ http {{ .Host }}/ip
+{{ .IP }}
+{{ if .Port }} +

Port testing

+
+$ http {{ .Host }}/port/8080
+{
+  "ip": "{{ .IP }}",
+  "port": 8080,
+  "reachable": false
+}
+{{ end }} +
+{{ if .City }} +
+

Map

+ +
+{{ end }} +
+

FAQ

+

How do I force IPv4 or IPv6 lookup?

+

As of 2018-07-25 it's no longer possible to force protocol using + the v4 and v6 subdomains. IPv4 or IPv6 still can be forced + by passing the appropiate flag to your client, e.g curl -4 + or curl -6.

+ +

Is automated use of this service permitted?

+

+ Yes, as long as the rate limit is respected. The rate limit is in + place to ensure a fair service for all. +

+

+ Please limit automated requests to 1 request per minute. No + guarantee is made for requests that exceed this limit. They may be + rate-limited, with a 429 status code, or dropped entirely. +

+ +

Can I run my own service?

+

Yes, the source code and documentation is available on GitHub.

+
+
+ + {{ if or .Country .City .ASN .ASNOrg }} +
+ +
+ {{ end }} + +