Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error only .torrent files #19

Closed
Pupwiz opened this issue Mar 12, 2022 · 16 comments
Closed

Error only .torrent files #19

Pupwiz opened this issue Mar 12, 2022 · 16 comments

Comments

@Pupwiz
Copy link

Pupwiz commented Mar 12, 2022

I'm not sure what I may be missing.
Everything seem to be working and all categories etc. show up.
Account created access seem to work. Doing a test with the debian net ISO and or any other torrent and I get " only
.torrent files can be uploaded" even though they are .torrent files.

@mickvandijke
Copy link
Member

Could you send me some of those .torrent files that don't work? I would like to try them for myself and see what's going wrong :)

@Pupwiz
Copy link
Author

Pupwiz commented Mar 13, 2022

I have to think something on my setup is wrong or causing the issue. I actually tried to add the debian torrent.
https://cdimage.debian.org/debian-cd/current/amd64/bt-cd/debian-11.2.0-amd64-netinst.iso.torrent
and it's not allowing even it. I have it set to test on a none https nginx server. As it wont take a known working torrent I would have to believe it's my setting or permissions that would be causing this to happen. This isn't getting to the nginx error log and I'm not quite sure how to debug the backend of torrust to see if it is a permission problem.

@mickvandijke
Copy link
Member

mickvandijke commented Mar 13, 2022

I could upload the debian torrent just fine to my demo Torrust: https://torrust.dutchbits.nl/torrent/2/Debian.ISO .

I think it has something to do with your NGINX client_max_body_size setting being too low: https://docs.rackspace.com/support/how-to/limit-file-upload-size-in-nginx/#:~:text=By%20default%2C%20NGINX®%20has,location%20block%20to%20edit%20client_max_body_size.

@Pupwiz
Copy link
Author

Pupwiz commented Mar 14, 2022

So I ditched everything last night and did a default install on my test box.
Running Debian 11.2 and using guide from website install page. This is all bone stock (fresh install of all on kvm nothing else but the required packages that are on the install page) without changing anything except external ip and running from the browser with IP. Defaults all load on server, nginx loads /dist folder and displays all as expected, creates a new account with user and pass. Lets me add categories etc, adjust settings page to my liking.
There are no errors in nginx's error logs performing any of the task. I would think that max body would throw an error complaining that it was to low but add and adjusted anyway.
Did a check on access logs and it's throwing
[14/Mar/2022:13:18:13 -0400] "POST /api/torrent/upload HTTP/1.1" 400
the backend defaults say ./uploads so change it to upload thinking this was causing the issues and restarted backend.
page throws "error only .torrent files can be uploaded."
This seems to be a permission problem but I can't trace anything as the backend doesn't throw out anything even with trace setting on.
all other request on access log are HTTP/1.1" 200 220 like setting configs user etc.
I'll have to leave it for a bit as without having a debug I really can't see what the issues are. I would have to surmise that the backend either cant talk to something or cant access the upload folder.

@mickvandijke
Copy link
Member

I'm sorry for the issues you're running into. I will investigate this right now and let you know what I find.

@mickvandijke
Copy link
Member

So the error "only .torrent files can be uploaded." gets thrown when the torrent field in the upload POST request does not have the type "application/x-bittorrent". Are you uploading the torrent through the Torrust Index upload form?

@Pupwiz
Copy link
Author

Pupwiz commented Mar 14, 2022

Yes. I haven't tried it from server directly as loading from the cli wouldn't be useful. Not sure I would know how to make that work even from reading the guide.
This isn't a big rush issue. I have no issues using the torrust-tracker (running without any issue) with a public trackers and a private torrent. This just would be really nice addition to my site and servers.
16472822752167678126119401703841
16472823220051871945482715028022

@jamiew0w
Copy link

@Pupwiz what browser are you using?

type=application/x-bittorrent needs to be specified (and should be by default in your browser) but it seems like that's being stripped somehow. If it doesn't work in other browsers, how does your nginx config look?

@Pupwiz
Copy link
Author

Pupwiz commented Mar 16, 2022

Tried both browser types - Edge / Chrome . Noticed Nginx didn't have mime type for .torrent and added it to the mime types

nignx default

server {
listen 80;
client_max_body_size 100M;
root /home/media/torrust/frontend/dist/;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
#return 301 https://$host$request_uri;
location / {
try_files $uri $uri/ /index.html;
}

location /api/ {
    proxy_pass http://127.0.0.1:3000/;
}

}

Access logs to nginx show that GET request are 200 and all post are 400.
I'm testing on bare bone system but did think maybe something on my test server wasn't working so I move to production for a test with the same resulsts.
Browsers didn't seem to have any change
adding .torrent to mime also didn't have any real effect
192.168.1.1 - - [16/Mar/2022:10:54:38 -0400] "POST /api/torrent/upload HTTP/1.1" 400 47 "http://192.168.1.121/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39" 192.168.1.1 - - [16/Mar/2022:10:54:45 -0400] "POST /api/torrent/upload HTTP/1.1" 400 47 "http://192.168.1.121/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36" 127.0.0.1 - - [16/Mar/2022:10:56:45 -0400] "GET /api/torrent/upload HTTP/1.1" 405 0 "-" "curl/7.74.0" 192.168.1.230 - - [16/Mar/2022:11:06:04 -0400] "GET /upload HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36" 192.168.1.1 - - [16/Mar/2022:11:06:05 -0400] "GET /api/settings/name HTTP/1.1" 200 23 "http://192.168.1.121/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36" 192.168.1.1 - - [16/Mar/2022:11:06:05 -0400] "GET /api/category HTTP/1.1" 200 187 "http://192.168.1.121/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36" 192.168.1.1 - - [16/Mar/2022:11:06:05 -0400] "GET /api/category HTTP/1.1" 200 187 "http://192.168.1.121/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36" 106.75.229.12 - - [16/Mar/2022:11:06:16 -0400] "GET / HTTP/1.0" 200 747 "-" "-" 192.168.1.1 - - [16/Mar/2022:11:06:27 -0400] "POST /api/torrent/upload HTTP/1.1" 400 47 "http://192.168.1.121/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36"

Also tried these recommends

[cannot-post-to-api-location-using-nginx]https://stackoverflow.com/questions/63893651/cannot-post-to-api-location-using-nginx]

console log from chrome
Screenshot 2022-03-16 180619

@jamiew0w
Copy link

Have you tried cutting out Nginx and uploading directly via the API?

curl -X POST 'http://localhost:3000/torrent/upload' \
-H 'Content-Type: multipart/form-data' \
-H 'Authorization: Bearer TOKENHERE' \
-F 'torrent=@"/path/to/your.torrent";type=application/x-bittorrent' \
-F 'title="TITLE"' \
-F 'description="DESCRIPTION"' \
-F 'category="CATEGORY"'

If that works we'll know the issue lays with Nginx.
Can grab the token via browser console -> storage or here

@Pupwiz
Copy link
Author

Pupwiz commented Mar 17, 2022

So I didn't try it until you suggested it. Found my bearer token in the browser console and added it manually. It has no problem taking it by issuing the above.
curl -X POST 'http://localhost:3000/torrent/upload' -H 'Content-Type: multipart/form-data' -H 'Authorization: Bearer eyXXXX' -F 'torrent=@"/home/media/debian-11.2.0-amd64-netinst.iso.torrent";type=application/x-bittorrent' -F 'title="Debian 11.2 iso "' -F 'description="Debian 11.2 Net install iso "' -F 'category="software"'
{"data":{"torrent_id":2}}
Add the torrent and tracker took the torrent.
So I would assume I have something with nginx that is not allowing it to post.
nginx version: nginx/1.18.0
built with OpenSSL 1.1.1k 25 Mar 2021
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -ffile-prefix-map=/build/nginx-q9LD4J/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_geoip_module=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-headers-more-filter --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-auth-pam --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-cache-purge --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-dav-ext --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-ndk --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-echo --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-fancyindex --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-geoip2 --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/nchan --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-lua --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/rtmp --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-uploadprogress --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-upstream-fair --add-dynamic-module=/build/nginx-q9LD4J/nginx-1.18.0/debian/modules/http-subs-filte

@Pupwiz
Copy link
Author

Pupwiz commented Mar 17, 2022

My nginx server configs
upstream transmission {
server 192.168.1.121:9091;
keepalive 4;
}

upstream netdata {
server 192.168.1.121:19999;
keepalive 64;
}

server {
client_max_body_size 100M;
root /home/media/torrust/frontend/dist/;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name xx.com www.xx.com;
#return 301 https://$host$request_uri;
location / {
try_files $uri $uri/ /index.html;
}

location /api/ {
    proxy_pass http://127.0.0.1:3000/;
}
 	# pass PHP scripts to FastCGI server
    location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}

location = /netdata {
return 301 /netdata/;
}

location ~ /netdata/(?<ndpath>.*) {
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_pass_request_headers on;
    proxy_set_header Connection "keep-alive";
    proxy_store off;
    proxy_pass http://netdata/$ndpath$is_args$args;
    gzip on;
    gzip_proxied any;
    gzip_types *;
}

}
server {

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
client_body_buffer_size    1M;
client_max_body_size       7G;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
    server_name xx.com www.xx.com; # managed by Certbot
# pass PHP scripts to FastCGI server
#
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/xx.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xx.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;

}

include /etc/nginx/apps/*;
location ~ /.ht {
deny all;
}
}

@Pupwiz
Copy link
Author

Pupwiz commented Mar 17, 2022

Yes?
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 524288;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
   #tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

}

@Pupwiz
Copy link
Author

Pupwiz commented Mar 18, 2022

This doesn't require nginx upload progress module does it?

@mickvandijke
Copy link
Member

No, I'm just using a default NGINX setup. I honestly have no idea why it isn't working for you.

@Pupwiz
Copy link
Author

Pupwiz commented Mar 23, 2022

So today I discovered by doing some testing that Asus router is blocking the upload function so there is nothing wrong with the scripts. I'll start a new thread for this issue.

@Pupwiz Pupwiz closed this as completed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants