2021-01-02 22:17:51 +01:00
|
|
|
{ ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
"ip.clerie.de" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2023-03-15 21:00:53 +01:00
|
|
|
locations."= /" = {
|
2021-01-02 22:17:51 +01:00
|
|
|
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>Use bash and curl: <code>curl ip{4,6}.clerie.de</code></p>
|
|
|
|
<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>'
|
|
|
|
'';
|
|
|
|
extraConfig = ''
|
|
|
|
types { } default_type "text/html; charset=utf-8";
|
|
|
|
'';
|
|
|
|
};
|
2023-03-15 21:00:53 +01:00
|
|
|
extraConfig = ''
|
|
|
|
access_log /var/log/nginx/ip.clerie.de.log vcombined_anon;
|
|
|
|
'';
|
2021-01-02 22:17:51 +01:00
|
|
|
};
|
|
|
|
"ip4.clerie.de" = {
|
|
|
|
enableACME = true;
|
2021-01-14 13:45:15 +01:00
|
|
|
addSSL = true;
|
2023-03-15 21:00:53 +01:00
|
|
|
locations."= /" = {
|
2021-01-02 22:17:51 +01:00
|
|
|
return = ''200 "$remote_addr\n"'';
|
|
|
|
extraConfig = ''
|
|
|
|
types { } default_type "text/plain; charset=utf-8";
|
|
|
|
add_header Access-Control-Allow-Origin *;
|
|
|
|
'';
|
|
|
|
};
|
2023-03-15 21:00:53 +01:00
|
|
|
extraConfig = ''
|
|
|
|
access_log /var/log/nginx/ip.clerie.de.log vcombined_anon;
|
|
|
|
'';
|
2021-01-02 22:17:51 +01:00
|
|
|
};
|
|
|
|
"ip6.clerie.de" = {
|
|
|
|
enableACME = true;
|
2021-01-14 13:45:15 +01:00
|
|
|
addSSL = true;
|
2023-03-15 21:00:53 +01:00
|
|
|
locations."= /" = {
|
2021-01-02 22:17:51 +01:00
|
|
|
return = ''200 "$remote_addr\n"'';
|
|
|
|
extraConfig = ''
|
|
|
|
types { } default_type "text/plain; charset=utf-8";
|
|
|
|
add_header Access-Control-Allow-Origin *;
|
|
|
|
'';
|
|
|
|
};
|
2023-03-15 21:00:53 +01:00
|
|
|
extraConfig = ''
|
|
|
|
access_log /var/log/nginx/ip.clerie.de.log vcombined_anon;
|
|
|
|
'';
|
2021-01-02 22:17:51 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|