From ec2d857194a8c573cdcb76a59eada6a8e150ed19 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Thu, 17 Oct 2024 17:58:50 +0200 Subject: Setup obsidian-livesync --- machines/srv3/configuration.nix | 8 +++++--- modules/obsidian-livesync.nix | 24 +++++++++--------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/machines/srv3/configuration.nix b/machines/srv3/configuration.nix index 197aec6..d1fb4e2 100644 --- a/machines/srv3/configuration.nix +++ b/machines/srv3/configuration.nix @@ -4,6 +4,8 @@ let www = "/srv/www"; + domain = "niedzwiedzinski.cyou"; + in { imports = @@ -16,8 +18,8 @@ in services.obsidian-livesync = { enable = true; - domain = "obsidian.niedzwiedzinski.cyou"; - couchdb.adminPass = "123"; + domain = "obsidian.${domain}"; + adminsFile = "/etc/couchdb.ini"; }; boot.loader.grub.enable = true; @@ -36,7 +38,7 @@ in }; hostName = "srv3"; extraHosts = '' - 192.168.1.136 srv3.niedzwiedzinski.cyou git.niedzwiedzinski.cyou tmp.niedzwiedzinski.cyou zhr.niedzwiedzinski.cyou help.niedzwiedzinski.cyou niedzwiedzinski.cyou pics.niedzwiedzinski.cyou fresh.niedzwiedzinski.cyou + 192.168.1.136 srv3.niedzwiedzinski.cyou git.niedzwiedzinski.cyou tmp.niedzwiedzinski.cyou zhr.niedzwiedzinski.cyou help.niedzwiedzinski.cyou niedzwiedzinski.cyou pics.niedzwiedzinski.cyou fresh.niedzwiedzinski.cyou obsidian.${domain} 192.168.1.144 srv2.niedzwiedzinski.cyou '' + lib.readFile ( pkgs.fetchurl { url = "https://raw.githubusercontent.com/StevenBlack/hosts/d2be343994aacdec74865ff8d159cf6e46359adf/alternates/fakenews-gambling-porn/hosts"; diff --git a/modules/obsidian-livesync.nix b/modules/obsidian-livesync.nix index 5841202..cfad4f3 100644 --- a/modules/obsidian-livesync.nix +++ b/modules/obsidian-livesync.nix @@ -58,14 +58,12 @@ in [httpd] WWW-Authenticate = Basic realm="couchdb" + enable_cors = true bind_address = 127.0.0.1 - + [cors] - origins = app://obsidian.md, capacitor://localhost, http://localhost - credentials = true - headers = accept, authorization, content-type, origin, referer - methods = GET,PUT,POST,HEAD,DELETE - max_age = 3600 + #origins = app://obsidian.md,capacitor://localhost,http://localhost + #credentials = true ''; }; @@ -81,17 +79,13 @@ in proxy_set_header X-Real-IP "$remote_addr"; proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for"; proxy_set_header X-Forwarded-Proto "$scheme"; - add_header Access-Control-Allow-Origin "app://obsidian.md"; - add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"; - add_header Access-Control-Allow-Headers "Content-Type, Authorization"; - add_header Access-Control-Allow-Credentials "true"; - add_header Access-Control-Max-Age 86400; + add_header Access-Control-Allow-Origin "app://obsidian.md" always; + add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; + add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; + add_header Access-Control-Allow-Credentials "true" always; + add_header Access-Control-Max-Age 86400 always; if ($request_method = OPTIONS) { - add_header Access-Control-Allow-Origin "app://obsidian.md"; - add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"; - add_header Access-Control-Allow-Headers "Content-Type, Authorization"; - add_header Access-Control-Allow-Credentials "true"; return 204; } ''; -- cgit 1.4.1 From 2eb1a14886e5290357285cab62e5ff5662b2fd56 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Fri, 18 Oct 2024 22:40:15 +0200 Subject: android hackaround --- modules/obsidian-livesync.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/obsidian-livesync.nix b/modules/obsidian-livesync.nix index cfad4f3..e576eb0 100644 --- a/modules/obsidian-livesync.nix +++ b/modules/obsidian-livesync.nix @@ -79,7 +79,7 @@ in proxy_set_header X-Real-IP "$remote_addr"; proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for"; proxy_set_header X-Forwarded-Proto "$scheme"; - add_header Access-Control-Allow-Origin "app://obsidian.md" always; + add_header Access-Control-Allow-Origin "$http_origin" always; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; add_header Access-Control-Allow-Credentials "true" always; -- cgit 1.4.1