From dc6e4936ed8200ad6e15f7e97ad066939846c23a Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Wed, 6 Mar 2024 09:16:35 -0500 Subject: [PATCH] don't require proxy server --- README.md | 25 +++---------------------- configuration.nix | 13 ++++++++++++- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 5e9c8de..4b35f76 100644 --- a/README.md +++ b/README.md @@ -5,33 +5,14 @@ nixos-rebuild build-vm --flake .#mastodon ./result/bin/run-nixos-vm ``` -Now you can access mastodon at +Now you can access mastodon at - You will have to "accept the security risk". - It may take a minute for the webpage to come online. Until then you will see 502 Bad Gateway Remember that if you want to clear the state from one launch to the next, you should delete the `nixos.qcow2` file that is created. -# Account creation / access - -Mastodon throws a hissyfit when trying to create accounts / login if it's not being **accessed** on port 443. This is a problem with the way we've set up port forwarding. - -My current (terrible) solution is to run -``` -nixos-rebuild build-vm --flake .#mastodon - -# start a proxy server to the server on port 1234 (you can pick your favourite port) -ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=Error -D 1234 root@localhost -p 2222 - -# optional. create a new firefox profile so we don't have to undo the settings when we're done -mkdir /tmp/profile && firefox --profile /tmp/profile -``` - -Then configure Firefox by going to `about:config` and setting `network.proxy.allow_hijacking_localhost` to `true`, and in `about:preferences` set the proxy to manual `localhost` port `1234`, and enable `Proxy DNS` at the bottom. - -Navigate to , and click "create account" - -- email verification is WIP, but should be accessible at +- email, when it works, will be accessible at # TODOs @@ -48,7 +29,7 @@ Navigate to , and click "create account" - SEE: https://docs.joinmastodon.org/admin/scaling/ - [ ] remove the need for "accept security risk" dialogue if possible - [ ] development environment does not work seamlessly. -- [ ] don't require proxy server +- [x] don't require proxy server - either forward 443 directly, or get mastodon to accept connections on a different port (maybe 3000? see development environment documentation) - [ ] get letter_opener working diff --git a/configuration.nix b/configuration.nix index 85ca54d..b38c355 100644 --- a/configuration.nix +++ b/configuration.nix @@ -102,6 +102,9 @@ { virtualisation.vmVariant = { config, ... }: { services.mastodon = { + # needed so we can directly access mastodon at port 55001 + # otherwise, mastodon has to be accessed *from* port 443, which we can't do via port forwarding + enableUnixSocket = false; extraConfig = { RAILS_ENV = "development"; # for letter_opener @@ -138,9 +141,17 @@ rails db:seed else echo "Migrating database (this might be a noop)" - rails db:migrate + # TODO: this breaks for some reason + # rails db:migrate fi ''; + virtualisation.forwardPorts = lib.mkForce [ + { + from = "host"; + host.port = 55001; + guest.port = 55001; + } + ]; }; } ]