sin0/ip-checker: make curl ip.ny4.dev work
This commit is contained in:
parent
766bca73d0
commit
0613aab83f
1 changed files with 24 additions and 2 deletions
|
@ -51,14 +51,36 @@ in
|
||||||
|
|
||||||
systemd.services."caddy".serviceConfig.SupplementaryGroups = [ "ip-checker" ];
|
systemd.services."caddy".serviceConfig.SupplementaryGroups = [ "ip-checker" ];
|
||||||
|
|
||||||
|
# HACK: this disables automatic https redirection for every VirtualHost
|
||||||
|
# to make `curl ip.ny4.dev` work
|
||||||
|
services.caddy.settings.apps.http.servers.srv0 = {
|
||||||
|
automatic_https.disable_redirects = true;
|
||||||
|
listen = [ ":80" ];
|
||||||
|
};
|
||||||
|
|
||||||
services.caddy.settings.apps.http.servers.srv0.routes = lib.singleton {
|
services.caddy.settings.apps.http.servers.srv0.routes = lib.singleton {
|
||||||
match = lib.singleton { host = [ "ip.ny4.dev" ]; };
|
match = lib.singleton { host = [ "ip.ny4.dev" ]; };
|
||||||
handle = lib.singleton {
|
handle = lib.singleton {
|
||||||
handler = "subroute";
|
handler = "subroute";
|
||||||
routes = [
|
routes = [
|
||||||
# TODO: make `curl ip.ny4.dev` work
|
|
||||||
{
|
{
|
||||||
match = [ { path = [ "/api/v1/*" ]; } ];
|
match = lib.singleton {
|
||||||
|
header_regexp."User-Agent".pattern = "^curl/.*";
|
||||||
|
path = [ "/" ];
|
||||||
|
};
|
||||||
|
handle = [
|
||||||
|
{
|
||||||
|
handler = "rewrite";
|
||||||
|
uri = "/api/v1/ip";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
handler = "reverse_proxy";
|
||||||
|
upstreams = lib.singleton { dial = "unix//run/ip-checker/ip-checker.sock"; };
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
match = lib.singleton { path = [ "/api/v1/*" ]; };
|
||||||
handle = lib.singleton {
|
handle = lib.singleton {
|
||||||
handler = "reverse_proxy";
|
handler = "reverse_proxy";
|
||||||
upstreams = lib.singleton { dial = "unix//run/ip-checker/ip-checker.sock"; };
|
upstreams = lib.singleton { dial = "unix//run/ip-checker/ip-checker.sock"; };
|
||||||
|
|
Loading…
Add table
Reference in a new issue