[GH-ISSUE #34] Can't use magnet links and uploading torrent file while using authentication #26

Closed
opened 2026-02-25 20:32:12 +03:00 by kerem · 12 comments
Owner

Originally created by @Slyneth on GitHub (Apr 13, 2015).
Original GitHub issue: https://github.com/asapach/peerflix-server/issues/34

I am using peerflix-server on my VPS, I set it up like this:

server {
    listen 80;
    server_name peerflix.domain.com;
    keepalive_timeout 15m;

    location / {
            proxy_pass http://localhost:9000/;
            proxy_http_version 1.1;
            auth_basic "peerflix server";
            auth_basic_user_file /etc/nginx/.htpasswd;
    }

    location /socket.io/ {
            proxy_pass http://localhost:9000/socket.io/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    }
    location /torrents/ {
            proxy_pass http://localhost:9000/torrents/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    }
}

TCP 9000 port is blocked on the firewall.

I can drag and drop files, watch in local with mpv (couldn't watch without /torrents/), web page is password protected; but adding magnet links and clicking Download or using uploading function doesn't work.

And they work if I add 9000/tcp to my firewall and connect directly using domain.com:9000, but then authentication doesn't work.

Originally created by @Slyneth on GitHub (Apr 13, 2015). Original GitHub issue: https://github.com/asapach/peerflix-server/issues/34 I am using peerflix-server on my VPS, I set it up like this: ``` server { listen 80; server_name peerflix.domain.com; keepalive_timeout 15m; location / { proxy_pass http://localhost:9000/; proxy_http_version 1.1; auth_basic "peerflix server"; auth_basic_user_file /etc/nginx/.htpasswd; } location /socket.io/ { proxy_pass http://localhost:9000/socket.io/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /torrents/ { proxy_pass http://localhost:9000/torrents/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } ``` TCP 9000 port is blocked on the firewall. I can drag and drop files, watch in local with mpv (couldn't watch without /torrents/), web page is password protected; but adding magnet links and clicking Download or using uploading function doesn't work. And they work if I add 9000/tcp to my firewall and connect directly using domain.com:9000, but then authentication doesn't work.
kerem closed this issue 2026-02-25 20:32:12 +03:00
Author
Owner

@asapach commented on GitHub (Apr 13, 2015):

You don't need to specify proxy_set_header for /torrents/ -- those are only needed for socket.io.

<!-- gh-comment-id:92317796 --> @asapach commented on GitHub (Apr 13, 2015): You don't need to specify `proxy_set_header` for `/torrents/` -- those are only needed for `socket.io`.
Author
Owner

@Slyneth commented on GitHub (Apr 13, 2015):

Thanks, fixed it. But still doesn't work.

<!-- gh-comment-id:92318737 --> @Slyneth commented on GitHub (Apr 13, 2015): Thanks, fixed it. But still doesn't work.
Author
Owner

@asapach commented on GitHub (Apr 13, 2015):

And if you comment out the /torrents/ section, does it work?

<!-- gh-comment-id:92319325 --> @asapach commented on GitHub (Apr 13, 2015): And if you comment out the `/torrents/` section, does it work?
Author
Owner

@Slyneth commented on GitHub (Apr 13, 2015):

It works, but streaming to my local machine doesn't. HTTP authentication gets in the way.

<!-- gh-comment-id:92319923 --> @Slyneth commented on GitHub (Apr 13, 2015): It works, but streaming to my local machine doesn't. HTTP authentication gets in the way.
Author
Owner

@asapach commented on GitHub (Apr 13, 2015):

OK, could you try something like this:

server {
    listen 80;
    server_name peerflix.domain.com;
    keepalive_timeout 15m;

    location / {
        proxy_pass http://localhost:9000/;
        proxy_http_version 1.1;

        limit_except GET HEAD {
            auth_basic "peerflix server";
            auth_basic_user_file /etc/nginx/.htpasswd;
        }
    }

    location /socket.io/ {
        proxy_pass http://localhost:9000/socket.io/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

It should in theory only ask for password when you try to change something: POST, PUT or DELETE

<!-- gh-comment-id:92321814 --> @asapach commented on GitHub (Apr 13, 2015): OK, could you try something like this: ``` server { listen 80; server_name peerflix.domain.com; keepalive_timeout 15m; location / { proxy_pass http://localhost:9000/; proxy_http_version 1.1; limit_except GET HEAD { auth_basic "peerflix server"; auth_basic_user_file /etc/nginx/.htpasswd; } } location /socket.io/ { proxy_pass http://localhost:9000/socket.io/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } ``` It should in theory only ask for password when you try to change something: `POST`, `PUT` or `DELETE`
Author
Owner

@Slyneth commented on GitHub (Apr 13, 2015):

Doesn't work. Streaming does but magnets and upload doesn't.

<!-- gh-comment-id:92322358 --> @Slyneth commented on GitHub (Apr 13, 2015): Doesn't work. Streaming does but magnets and upload doesn't.
Author
Owner

@asapach commented on GitHub (Apr 13, 2015):

Do you see any errors in the logs? In the browser console? Can you paste request/response here?

<!-- gh-comment-id:92323909 --> @asapach commented on GitHub (Apr 13, 2015): Do you see any errors in the logs? In the browser console? Can you paste request/response here?
Author
Owner

@Slyneth commented on GitHub (Apr 13, 2015):

My config and yours gives the same error:

Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an object but got an array
http://errors.angularjs.org/1.2.28/$resource/badcfg?p0=object&p1=array
    at 07413d7e.vendor.js:3
    at a.then.A.$resolved (07413d7e.vendor.js:7)
    at k (07413d7e.vendor.js:5)
    at k (07413d7e.vendor.js:5)
    at 07413d7e.vendor.js:5
    at k.$eval (07413d7e.vendor.js:5)
    at k.$digest (07413d7e.vendor.js:5)
    at k.$apply (07413d7e.vendor.js:5)
    at i (07413d7e.vendor.js:4)
    at r (07413d7e.vendor.js:4)07413d7e.vendor.js:5 (anonymous function)07413d7e.vendor.js:4 (anonymous function)07413d7e.vendor.js:5 k07413d7e.vendor.js:5 k07413d7e.vendor.js:5 (anonymous function)07413d7e.vendor.js:5 k.$eval07413d7e.vendor.js:5 k.$digest07413d7e.vendor.js:5 k.$apply07413d7e.vendor.js:4 i07413d7e.vendor.js:4 r07413d7e.vendor.js:4 w.onreadystatechange
<!-- gh-comment-id:92324358 --> @Slyneth commented on GitHub (Apr 13, 2015): My config and yours gives the same error: ``` Error: [$resource:badcfg] Error in resource configuration. Expected response to contain an object but got an array http://errors.angularjs.org/1.2.28/$resource/badcfg?p0=object&p1=array at 07413d7e.vendor.js:3 at a.then.A.$resolved (07413d7e.vendor.js:7) at k (07413d7e.vendor.js:5) at k (07413d7e.vendor.js:5) at 07413d7e.vendor.js:5 at k.$eval (07413d7e.vendor.js:5) at k.$digest (07413d7e.vendor.js:5) at k.$apply (07413d7e.vendor.js:5) at i (07413d7e.vendor.js:4) at r (07413d7e.vendor.js:4)07413d7e.vendor.js:5 (anonymous function)07413d7e.vendor.js:4 (anonymous function)07413d7e.vendor.js:5 k07413d7e.vendor.js:5 k07413d7e.vendor.js:5 (anonymous function)07413d7e.vendor.js:5 k.$eval07413d7e.vendor.js:5 k.$digest07413d7e.vendor.js:5 k.$apply07413d7e.vendor.js:4 i07413d7e.vendor.js:4 r07413d7e.vendor.js:4 w.onreadystatechange ```
Author
Owner

@Slyneth commented on GitHub (Apr 13, 2015):

I have managed to get Download button working, uploading still doesn't. But uploading isn't that important, I can drag&drop files. And all the page is protected this way:

server {
    listen 80;
    server_name peerflix.domain.com;
    keepalive_timeout 15m;

    location / {
            proxy_pass http://localhost:9000/;
            proxy_http_version 1.1;
            auth_basic "peerflix server";
            auth_basic_user_file /etc/nginx/.htpasswd;
    }

    location /socket.io/ {
            proxy_pass http://localhost:9000/socket.io/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    }
    location /torrents {
            proxy_pass http://localhost:9000/torrents;
            proxy_http_version 1.1;
    }
}

Streaming to local works well too.

<!-- gh-comment-id:92326625 --> @Slyneth commented on GitHub (Apr 13, 2015): I have managed to get Download button working, uploading still doesn't. But uploading isn't that important, I can drag&drop files. And all the page is protected this way: ``` server { listen 80; server_name peerflix.domain.com; keepalive_timeout 15m; location / { proxy_pass http://localhost:9000/; proxy_http_version 1.1; auth_basic "peerflix server"; auth_basic_user_file /etc/nginx/.htpasswd; } location /socket.io/ { proxy_pass http://localhost:9000/socket.io/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /torrents { proxy_pass http://localhost:9000/torrents; proxy_http_version 1.1; } } ``` Streaming to local works well too.
Author
Owner

@asapach commented on GitHub (Apr 13, 2015):

It seems like the upload button is broken even without nginx proxy. Created a new bug: #35
Do magnet links work?

<!-- gh-comment-id:92333053 --> @asapach commented on GitHub (Apr 13, 2015): It seems like the upload button is broken even without nginx proxy. Created a new bug: #35 Do magnet links work?
Author
Owner

@Slyneth commented on GitHub (Apr 13, 2015):

Magnet links and torrent download links work in the last config I pasted. Problem was /torrents/, /torrents fixed it.

Thanks for your help =)

<!-- gh-comment-id:92333236 --> @Slyneth commented on GitHub (Apr 13, 2015): Magnet links and torrent download links work in the last config I pasted. Problem was /torrents/, /torrents fixed it. Thanks for your help =)
Author
Owner

@asapach commented on GitHub (Apr 13, 2015):

np

<!-- gh-comment-id:92333300 --> @asapach commented on GitHub (Apr 13, 2015): np
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/peerflix-server#26
No description provided.