torrust / torrust-demo

CI and configuration for the Torrust live demo.
https://index.torrust-demo.com
0 stars 0 forks source link

Error on HTTP tracker announce request after updating the demo #7

Closed josecelano closed 4 months ago

josecelano commented 4 months ago

I have updated the demo and I'm getting this error trying to make an HTTP announce request:

$ cargo run --bin http_tracker_client announce http://tracker.torrust-demo.com:7070 9c38422213e30bff212b30c360d26f9a02136422 
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.09s
     Running `target/debug/http_tracker_client announce 'http://tracker.torrust-demo.com:7070' 9c38422213e30bff212b30c360d26f9a02136422`
thread 'main' panicked at /home/josecelano/Documents/git/committer/me/github/torrust/torrust-tracker/src/console/clients/http/app.rs:74:29:
response body should be a valid announce response, got: "b"d14:failure reason187:Error resolving peer IP: missing or invalid the right most X-Forwarded-For IP (mandatory on reverse proxy tracker configuration) in src/servers/http/v1/services/peer_ip_resolver.rs:131:23e""
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

New tracker config file

[logging]
log_level = "info"

[core]
mode = "public"

[core.tracker_policy]
persistent_torrent_completed_stat = true

[core.announce_policy]
interval = 300
interval_min = 300

[core.net]
on_reverse_proxy = true

[core.database]
driver = "Sqlite3"
path = "/var/lib/torrust/tracker/database/sqlite3.db"

[[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"

Previous tracker config file

announce_interval = 300
db_driver = "Sqlite3"
db_path = "/var/lib/torrust/tracker/database/sqlite3.db"
external_ip = "0.0.0.0"
inactive_peer_cleanup_interval = 600
log_level = "info"
max_peer_timeout = 900
min_announce_interval = 300
mode = "public"
on_reverse_proxy = true
persistent_torrent_completed_stat = true
remove_peerless_torrents = true
tracker_usage_statistics = true

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

[[http_trackers]]
bind_address = "0.0.0.0:7070"
enabled = true
ssl_cert_path = "/var/lib/torrust/tracker/tls/localhost.crt"
ssl_enabled = false
ssl_key_path = "/var/lib/torrust/tracker/tls/localhost.key"

[http_api]
bind_address = "0.0.0.0:1212"
enabled = true
ssl_cert_path = "/var/lib/torrust/tracker/tls/localhost.crt"
ssl_enabled = false
ssl_key_path = "/var/lib/torrust/tracker/tls/localhost.key"

# Please override the admin token setting the
#    `TORRUST_TRACKER_API_ADMIN_TOKEN`
#                     environmental variable!

[http_api.access_tokens]
admin = "MyAccessToken"

[health_check_api]
bind_address = "127.0.0.1:1313"
josecelano commented 4 months ago

The problem was I was making the request directly to the tracker container:

http://tracker.torrust-demo.com:7070

Instead of using the proxy (nginx):

https://tracker.torrust-demo.com

The error was OK; the tracker configuration enabled the reverse proxy with:

[core.net]
on_reverse_proxy = true

However, the request does not contain the X-Forwarded-For header since we are not using the proxy for the request.

$ cargo run --bin http_tracker_client announce https://tracker.torrust-demo.com 9c38422213e30bff212b30c360d26f9a02136422 | jq
    Finished `dev` profile [optimized + debuginfo] target(s) in 0.09s
     Running `target/debug/http_tracker_client announce 'https://tracker.torrust-demo.com' 9c38422213e30bff212b30c360d26f9a02136422`
{
  "complete": 1,
  "incomplete": 0,
  "interval": 300,
  "min interval": 300,
  "peers": []
}