Novage / wt-tracker

High-performance WebTorrent tracker
Apache License 2.0
253 stars 88 forks source link

Running behind nginx on subdirectory possible? #34

Closed danielfomin96 closed 3 years ago

danielfomin96 commented 3 years ago

I am trying to setup wt-tracker to run behind nginx on https://example.com/wt but I am not able to curl https://example.com/wt/stats.json even though I can connect with wscat.

my config.json:

{
  "servers": [{
      "server": {
        "port": 19823,
        "host": "127.0.0.1"
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1,
        "maxConnections": 100
      }
    }
  ],

  "tracker": {
    "maxOffers": 20,
    "announceInterval": 120
  },

  "websocketsAccess": {
    "allowOrigins": ["https://example.com"],
    "denyEmptyOrigin": true
  }
}

nginx entry:

location /wt {
            proxy_pass http://127.0.0.1:19823/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
}

Do I need to change "path": "/*", to something else? "/wt/*" did not work for me as I got error 404 with wscat. Is it even possible that such a setup succeeds? I am trying to curl stats.json because I want to know that wt-tracker works correctly.

danielfomin96 commented 3 years ago

I solved it for me by changing the nginx entry to: ´´´ location = /wt { proxy_pass http://127.0.0.1:19823/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; } location /wt/ { proxy_pass http://127.0.0.1:19823/; proxy_http_version 1.1; proxy_set_header Host $host; } ´´´