cache ip geolocate requests to ipinfo.io
This commit is contained in:
parent
63998d1033
commit
f387a27386
@ -17,6 +17,19 @@
|
|||||||
machines.phone.pubkey
|
machines.phone.pubkey
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# save ip addresses in cache from repeat logins
|
||||||
|
services.nginx.virtualHosts."localhost" = {
|
||||||
|
listen = [{ addr = "127.0.0.1"; port = 9414; }];
|
||||||
|
extraConfig = ''
|
||||||
|
location / {
|
||||||
|
proxy_pass_request_headers off;
|
||||||
|
proxy_pass https://ipinfo.io/;
|
||||||
|
proxy_cache_key $scheme://$host$uri$is_args$query_string;
|
||||||
|
proxy_cache_valid 203 1d;
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
environment.etc."ssh/sshrc".text = ''
|
environment.etc."ssh/sshrc".text = ''
|
||||||
login_ip="''${SSH_CLIENT%% *}"
|
login_ip="''${SSH_CLIENT%% *}"
|
||||||
is_in_ignored=$(grep "$login_ip" /etc/ssh/ignored_ips -c)
|
is_in_ignored=$(grep "$login_ip" /etc/ssh/ignored_ips -c)
|
||||||
@ -26,7 +39,7 @@
|
|||||||
fi
|
fi
|
||||||
time=$(date "+%T%:z")
|
time=$(date "+%T%:z")
|
||||||
geodata=$(
|
geodata=$(
|
||||||
curl -s ipinfo.io/$login_ip |
|
curl -s 127.0.0.1:9414/$login_ip |
|
||||||
sed '1d;$d;/readme/d;s/^ //g'
|
sed '1d;$d;/readme/d;s/^ //g'
|
||||||
)
|
)
|
||||||
${pkgs.mailutils}/bin/mail \
|
${pkgs.mailutils}/bin/mail \
|
||||||
|
Loading…
Reference in New Issue
Block a user