ip.clerie.de/ip.clerie.de

85 lines
2.3 KiB
Plaintext
Raw Normal View History

2020-10-18 15:48:01 +02:00
server {
listen 80;
listen [::]:80;
server_name ip.clerie.de ip4.clerie.de ip6.clerie.de;
return 301 https://$host$request_uri;
}
server {
listen [::]:443 ssl;
listen 443 ssl;
server_name ip.clerie.de;
ssl_certificate /etc/letsencrypt/live/ip.clerie.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ip.clerie.de/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
add_header Content-Type text/html;
return 200 '
<html>
<head>
<title>ip.clerie.de</title>
<script>
function httpGet(url, loaded, error) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url + ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime(), true);
xmlHttp.onload = () => {
if(xmlHttp.status == 200) {
loaded(xmlHttp.responseText);
}
else {
error();
}
};
xmlHttp.onerror = () => {error();};
xmlHttp.send(null);
}
function setText(id, text) {
document.getElementById(id).innerText = text;
}
httpGet("https://ip4.clerie.de/",
(response) => {setText("ip4", response);},
() => {setText("ip4", "Error");}
);
httpGet("https://ip6.clerie.de/",
(response) => {setText("ip6", response);},
() => {setText("ip6", "Error");}
);
</script>
</head>
<body>
<h1>ip.clerie.de</h1>
<ul>
<li><b>IPv6:</b> <span id="ip6">Loading...</span></li>
<li><b>IPv4:</b> <span id="ip4">Loading...</span></li>
</ul>
<p><small>Because any other "Whats my IP?"-tool sucks. <a href="https://git.clerie.de/clerie/ip.clerie.de">Host yourself :3</a></small></p>
</body>
</html>
';
}
}
server {
listen [::]:443 ssl;
listen 443 ssl;
server_name ip4.clerie.de ip6.clerie.de;
ssl_certificate /etc/letsencrypt/live/ip.clerie.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ip.clerie.de/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
add_header Content-Type text/plain;
add_header Access-Control-Allow-Origin *;
return 200 $remote_addr;
}
}