build: Default port to 4413

This commit is contained in:
2026-03-14 17:37:37 +01:00
parent 708e26e4f4
commit 19664ac56c
7 changed files with 17 additions and 17 deletions

View File

@@ -48,12 +48,12 @@ mix setup
mix run --no-halt mix run --no-halt
``` ```
Server listens on `http://localhost:4000` by default. Server listens on `http://localhost:4413` by default.
WebSocket clients should connect to: WebSocket clients should connect to:
```text ```text
ws://localhost:4000/relay ws://localhost:4413/relay
``` ```
### Useful endpoints ### Useful endpoints
@@ -76,7 +76,7 @@ Before a Nostr client can publish its first event successfully, make sure these
Set `DATABASE_URL` and create/migrate the database with `Parrhesia.Release.migrate()` or `mix ecto.migrate`. Set `DATABASE_URL` and create/migrate the database with `Parrhesia.Release.migrate()` or `mix ecto.migrate`.
2. Parrhesia is reachable behind your reverse proxy. 2. Parrhesia is reachable behind your reverse proxy.
Parrhesia itself listens on plain HTTP on port `4000`, and the reverse proxy is expected to terminate TLS and forward WebSocket traffic to `/relay`. Parrhesia itself listens on plain HTTP on port `4413`, and the reverse proxy is expected to terminate TLS and forward WebSocket traffic to `/relay`.
3. `:relay_url` matches the public relay URL clients should use. 3. `:relay_url` matches the public relay URL clients should use.
Set `PARRHESIA_RELAY_URL` to the public relay URL exposed by the reverse proxy. Set `PARRHESIA_RELAY_URL` to the public relay URL exposed by the reverse proxy.
@@ -91,7 +91,7 @@ In `prod`, these environment variables are used:
- `DATABASE_URL` (**required**), e.g. `ecto://USER:PASS@HOST/parrhesia_prod` - `DATABASE_URL` (**required**), e.g. `ecto://USER:PASS@HOST/parrhesia_prod`
- `POOL_SIZE` (optional, default `32`) - `POOL_SIZE` (optional, default `32`)
- `PORT` (optional, default `4000`) - `PORT` (optional, default `4413`)
- `PARRHESIA_*` runtime overrides for relay config, limits, policies, metrics, and features - `PARRHESIA_*` runtime overrides for relay config, limits, policies, metrics, and features
- `PARRHESIA_EXTRA_CONFIG` (optional path to an extra runtime config file) - `PARRHESIA_EXTRA_CONFIG` (optional path to an extra runtime config file)
@@ -129,7 +129,7 @@ CSV env vars use comma-separated values. Boolean env vars accept `1/0`, `true/fa
| Atom key | ENV | Default | Notes | | Atom key | ENV | Default | Notes |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `:relay_url` | `PARRHESIA_RELAY_URL` | `ws://localhost:4000/relay` | Advertised relay URL and auth relay tag target | | `:relay_url` | `PARRHESIA_RELAY_URL` | `ws://localhost:4413/relay` | Advertised relay URL and auth relay tag target |
| `:moderation_cache_enabled` | `PARRHESIA_MODERATION_CACHE_ENABLED` | `true` | Toggle moderation cache | | `:moderation_cache_enabled` | `PARRHESIA_MODERATION_CACHE_ENABLED` | `true` | Toggle moderation cache |
| `:enable_expiration_worker` | `PARRHESIA_ENABLE_EXPIRATION_WORKER` | `true` | Toggle background expiration worker | | `:enable_expiration_worker` | `PARRHESIA_ENABLE_EXPIRATION_WORKER` | `true` | Toggle background expiration worker |
| `:limits` | `PARRHESIA_LIMITS_*` | see table below | Runtime override group | | `:limits` | `PARRHESIA_LIMITS_*` | see table below | Runtime override group |
@@ -155,7 +155,7 @@ CSV env vars use comma-separated values. Boolean env vars accept `1/0`, `true/fa
| Atom key | ENV | Default | Notes | | Atom key | ENV | Default | Notes |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `:port` | `PORT` | `4000` | Main HTTP/WebSocket listener | | `:port` | `PORT` | `4413` | Main HTTP/WebSocket listener |
#### `Parrhesia.Web.MetricsEndpoint` #### `Parrhesia.Web.MetricsEndpoint`
@@ -299,7 +299,7 @@ Start the relay:
```bash ```bash
docker run --rm \ docker run --rm \
-p 4000:4000 \ -p 4413:4413 \
-e DATABASE_URL="ecto://USER:PASS@HOST/parrhesia_prod" \ -e DATABASE_URL="ecto://USER:PASS@HOST/parrhesia_prod" \
-e POOL_SIZE=20 \ -e POOL_SIZE=20 \
parrhesia:latest parrhesia:latest
@@ -333,13 +333,13 @@ docker compose up -d parrhesia
The relay will be available on: The relay will be available on:
```text ```text
ws://localhost:4000/relay ws://localhost:4413/relay
``` ```
Notes: Notes:
- `compose.yaml` keeps PostgreSQL in a separate container; the Parrhesia image only runs the app release. - `compose.yaml` keeps PostgreSQL in a separate container; the Parrhesia image only runs the app release.
- The container listens on port `4000`; use `PARRHESIA_HOST_PORT` if you want a different published host port. - The container listens on port `4413`; use `PARRHESIA_HOST_PORT` if you want a different published host port.
- Migrations are run explicitly through the one-shot `migrate` service instead of on every app boot. - Migrations are run explicitly through the one-shot `migrate` service instead of on every app boot.
- Common runtime overrides can go straight into `.env`; see [`.env.example`](./.env.example) for examples. - Common runtime overrides can go straight into `.env`; see [`.env.example`](./.env.example) for examples.
- For more specialized overrides, mount a file and set `PARRHESIA_EXTRA_CONFIG=/path/in/container/runtime.exs`. - For more specialized overrides, mount a file and set `PARRHESIA_EXTRA_CONFIG=/path/in/container/runtime.exs`.

View File

@@ -36,7 +36,7 @@ services:
DATABASE_URL: ${DATABASE_URL:-ecto://parrhesia:parrhesia@db:5432/parrhesia} DATABASE_URL: ${DATABASE_URL:-ecto://parrhesia:parrhesia@db:5432/parrhesia}
POOL_SIZE: ${POOL_SIZE:-20} POOL_SIZE: ${POOL_SIZE:-20}
ports: ports:
- "${PARRHESIA_HOST_PORT:-4000}:4000" - "${PARRHESIA_HOST_PORT:-4413}:4413"
volumes: volumes:
postgres-data: postgres-data:

View File

@@ -4,7 +4,7 @@ config :postgrex, :json_library, JSON
config :parrhesia, config :parrhesia,
moderation_cache_enabled: true, moderation_cache_enabled: true,
relay_url: "ws://localhost:4000/relay", relay_url: "ws://localhost:4413/relay",
limits: [ limits: [
max_frame_bytes: 1_048_576, max_frame_bytes: 1_048_576,
max_event_bytes: 262_144, max_event_bytes: 262_144,
@@ -68,7 +68,7 @@ config :parrhesia,
admin: Parrhesia.Storage.Adapters.Postgres.Admin admin: Parrhesia.Storage.Adapters.Postgres.Admin
] ]
config :parrhesia, Parrhesia.Web.Endpoint, port: 4000 config :parrhesia, Parrhesia.Web.Endpoint, port: 4413
config :parrhesia, Parrhesia.Web.MetricsEndpoint, config :parrhesia, Parrhesia.Web.MetricsEndpoint,
enabled: false, enabled: false,

View File

@@ -375,7 +375,7 @@ if config_env() == :prod do
queue_target: queue_target, queue_target: queue_target,
queue_interval: queue_interval queue_interval: queue_interval
config :parrhesia, Parrhesia.Web.Endpoint, port: int_env.("PORT", 4000) config :parrhesia, Parrhesia.Web.Endpoint, port: int_env.("PORT", 4413)
config :parrhesia, Parrhesia.Web.MetricsEndpoint, config :parrhesia, Parrhesia.Web.MetricsEndpoint,
enabled: enabled:

View File

@@ -47,7 +47,7 @@
Entrypoint = ["${parrhesia}/bin/parrhesia"]; Entrypoint = ["${parrhesia}/bin/parrhesia"];
Cmd = ["foreground"]; Cmd = ["foreground"];
ExposedPorts = { ExposedPorts = {
"4000/tcp" = {}; "4413/tcp" = {};
}; };
WorkingDir = "/"; WorkingDir = "/";
User = "65534:65534"; User = "65534:65534";
@@ -56,7 +56,7 @@
"LANG=C.UTF-8" "LANG=C.UTF-8"
"LC_ALL=C.UTF-8" "LC_ALL=C.UTF-8"
"MIX_ENV=prod" "MIX_ENV=prod"
"PORT=4000" "PORT=4413"
"RELEASE_DISTRIBUTION=none" "RELEASE_DISTRIBUTION=none"
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
]; ];

View File

@@ -10,7 +10,7 @@ defmodule Parrhesia.ConfigTest do
assert Parrhesia.Config.get([:limits, :auth_max_age_seconds]) == 600 assert Parrhesia.Config.get([:limits, :auth_max_age_seconds]) == 600
assert Parrhesia.Config.get([:limits, :max_outbound_queue]) == 256 assert Parrhesia.Config.get([:limits, :max_outbound_queue]) == 256
assert Parrhesia.Config.get([:limits, :max_filter_limit]) == 500 assert Parrhesia.Config.get([:limits, :max_filter_limit]) == 500
assert Parrhesia.Config.get([:relay_url]) == "ws://localhost:4000/relay" assert Parrhesia.Config.get([:relay_url]) == "ws://localhost:4413/relay"
assert Parrhesia.Config.get([:policies, :auth_required_for_writes]) == false assert Parrhesia.Config.get([:policies, :auth_required_for_writes]) == false
assert Parrhesia.Config.get([:policies, :marmot_media_max_imeta_tags_per_event]) == 8 assert Parrhesia.Config.get([:policies, :marmot_media_max_imeta_tags_per_event]) == 8
assert Parrhesia.Config.get([:policies, :marmot_media_reject_mip04_v1]) == true assert Parrhesia.Config.get([:policies, :marmot_media_reject_mip04_v1]) == true

View File

@@ -74,7 +74,7 @@ defmodule Parrhesia.Web.ConnectionTest do
end end
test "AUTH rejects relay tag mismatch" do test "AUTH rejects relay tag mismatch" do
state = connection_state(relay_url: "ws://localhost:4000/relay") state = connection_state(relay_url: "ws://localhost:4413/relay")
auth_event = valid_auth_event(state.auth_challenge, relay_url: "ws://attacker.example/relay") auth_event = valid_auth_event(state.auth_challenge, relay_url: "ws://attacker.example/relay")
payload = JSON.encode!(["AUTH", auth_event]) payload = JSON.encode!(["AUTH", auth_event])