Skip to content

Include public service URL in configuration #1417

Description

@josecelano

Relates to:

In the tracker configuration you can only specify the bind address for all services. It usually uses the wildcard IP:

[metadata]
app = "torrust-tracker"
purpose = "configuration"
schema_version = "2.0.0"

[logging]
threshold = "info"

[core]
listed = false
private = false

[[udp_trackers]]
bind_address = "0.0.0.0:6969"

[[http_trackers]]
bind_address = "0.0.0.0:7070"

[http_api]
bind_address = "0.0.0.0:1212"

Therefore the application does not know the public URLs for the services it's running.

Even if you bind one service to a concrete interface like for example:

[[http_trackers]]
bind_address = "203.0.113.0:7070"

The tracker could run behind a reverse proxy.

It would be good for some use cases if the application has that information. For example:

In metrics I'm working of exporting metrics with labels in the Prometheus format (see issue #1403):

announce_requests_received_total{ ip_version="ipv4", protocol="http", url="http://0.0.0.0:7070"} 1

scrape_requests_received_total{ ip_version="ipv4", protocol="http", url="http://0.0.0.0:7070"} 1

The label url is the listen URL. I'm planning to add a new instance label to identify the running app when you run more than one tracker. However, in more complex scenarios you could run one single tracker behind many different URls. For example:

All pointing to the same server (IP) running only one torrust tracker process. The "instance" would be the same.

There would be no way to calculate aggregate data per domain unless we include it as a label:

announce_requests_received_total{ ip_version="ipv4", protocol="http", url="http://0.0.0.0:7070" public_url="https://tracker1.torrust-demo.com/"} 1

scrape_requests_received_total{ ip_version="ipv4", protocol="http", url="http://0.0.0.0:7070" public_url="https://tracker2.torrust-demo.com/"} 1

My proposal is to add the public service URL to the config:

[metadata]
app = "torrust-tracker"
purpose = "configuration"
schema_version = "2.0.0"

[logging]
threshold = "info"

[core]
listed = false
private = false

[[udp_trackers]]
public_url = "udp://udp.torrust-demo.com"
bind_address = "0.0.0.0:6969"

[[http_trackers]]
public_url = "https://tracker.torrust-demo.com/announce"
bind_address = "0.0.0.0:7070"

[http_api]
public_url = "https://tracker.torrust-demo.com/api"
bind_address = "0.0.0.0:1212"

This is not a priority. I think the most important use case is metrics and it's not a common setup (I guess).

Activity

  1. added
    - Admin -
    on Mar 26, 2025
  2. added 3 commits that reference this issue on Jun 24, 2026
  3. josecelano commented on Jul 15, 2026

    @josecelano
    MemberAuthor

    Spec update (2026-07-15)

    This issue has been incorporated into EPIC #1978 — Configuration Overhaul (schema v3.0.0) as subissue #4 of 9.

    Spec: docs/issues/open/1417-1978-add-public-service-url-to-configuration.md

    Key design decisions

    Field placement: public_url is a flat field on each config struct (HttpTracker, UdpTracker, HttpApi, HealthCheckApi) — NOT inside the Network block being established by #1640. Rationale: Network groups network topology (how the tracker connects); public_url is about public exposure (how users reach the service). They are independently configurable.

    [[http_trackers]]
    bind_address = "0.0.0.0:7070"
    public_url = "https://tracker.torrust-demo.com/announce"   # flat, not inside [http_trackers.net]
    
    [http_trackers.net]
    external_ip = "203.0.113.5"
    on_reverse_proxy = true
    ipv6_v6only = false

    Protocol validation: The URL protocol is validated at deserialization time:

    • HTTP tracker: must use http:// or https://
    • UDP tracker: must use udp://
    • HTTP API / Health Check API: must use http:// or https://

    Scope: Config only — the field is stored and available for consumers (metrics, logs, health check). Runtime use in those systems is separate follow-up work.

    EPIC position: Depends on #1640 (subissue #3) for the Network block placement decision. Implemented after #1640 is complete.

  4. added a commit that references this issue on Jul 15, 2026
  5. self-assigned this
    on Jul 15, 2026
  6. added theissue type on Jul 15, 2026
  7. changed the issue type fromtoon Jul 15, 2026
  8. added 3 commits that reference this issue on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- Admin -Enhancement / Feature Request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions