Skip to content

Commit

Permalink
chore(devenv): add caddy server with https
Browse files Browse the repository at this point in the history
  • Loading branch information
kloenk committed Jul 20, 2023
1 parent a0f0d9c commit c23b677
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import Config

# Configure your database
if System.get_env("FLEETYARDS_IN_DEVENV") == "1" do
config :ex_fleet_yards_web, ExFleetYardsWeb.Endpoint,
url: [host: "fleetyards.localhost", port: 8443, scheme: "https"]

config :ex_fleet_yards_api, ExFleetYardsApi.Endpoint,
url: [host: "api.fleetyards.localhost", port: 8443, scheme: "https"]

config :ex_fleet_yards_auth, ExFleetYardsAuth.Endpoint,
url: [host: "auth.fleetyards.localhost", port: 8443, scheme: "https"]

config :boruta, Boruta.Oauth, issuer: "https://auth.fleetyards.net"
else
config :ex_fleet_yards, ExFleetYards.Repo,
username: "fleet_yards_dev",
Expand Down
30 changes: 30 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,36 @@
services.postgres.initialDatabases =
[{ name = "fleet_yards_dev"; }];
}
({ config, ... }: {
certificates = [
"fleetyards.localhost"
"api.fleetyards.localhost"
"auth.fleetyards.localhost"
];

services.caddy.enable = true;
services.caddy.config = ''
{
auto_https disable_redirects
}
'';
services.caddy.virtualHosts = let
elixir_host = port: {
extraConfig = ''
tls ${config.devenv.state}/mkcert/fleetyards.localhost+2.pem ${config.devenv.state}/mkcert/fleetyards.localhost+2-key.pem
reverse_proxy * http://localhost:${toString port}
'';
};
tls = name: ''
tls ${config.devenv.state}/mkcert/fleetyards.localhost+2.pem ${config.devenv.state}/mkcert/fleetyards.localhost+2-key.pem
auto_https disable_redirects'';
#"tls ${config.devenv.state}/mkcert/${name}.pem ${config.devenv.state}/mkcert/${name}-key.pem";
in {
"fleetyards.localhost:8443" = elixir_host 4000;
"auth.fleetyards.localhost:8443" = elixir_host 4002;
};
})
({ config, ... }: {
process.implementation = "hivemind";
scripts.devenv-up.exec = ''
Expand Down

0 comments on commit c23b677

Please sign in to comment.