diff --git a/README.md b/README.md index c1f07c74..89161c8e 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,7 @@ also see [comparison to similar software](./docs/versus.md) * ☑ ...of videos using FFmpeg * ☑ ...of audio (spectrograms) using FFmpeg * ☑ cache eviction (max-age; maybe max-size eventually) - * ☑ multilingual UI (english, norwegian, [add your own](./docs/rice/#translations))) + * ☑ multilingual UI (english, norwegian, chinese, [add your own](./docs/rice/#translations))) * ☑ SPA (browse while uploading) * server indexing * ☑ [locate files by contents](#file-search) @@ -1557,6 +1557,8 @@ you can either: * or do location-based proxying, using `--rp-loc=/stuff` to tell copyparty where it is mounted -- has a slight performance cost and higher chance of bugs * if copyparty says `incorrect --rp-loc or webserver config; expected vpath starting with [...]` it's likely because the webserver is stripping away the proxy location from the request URLs -- see the `ProxyPass` in the apache example below +when running behind a reverse-proxy (this includes services like cloudflare), it is important to configure real-ip correctly, as many features rely on knowing the client's IP. Look out for red and yellow log messages which explain how to do this. But basically, set `--xff-hdr` to the name of the http header to read the IP from (usually `x-forwarded-for`, but cloudflare uses `cf-connecting-ip`), and then `--xff-src` to the IP of the reverse-proxy so copyparty will trust the xff-hdr. Note that `--rp-loc` in particular will not work at all unless you do this + some reverse proxies (such as [Caddy](https://caddyserver.com/)) can automatically obtain a valid https/tls certificate for you, and some support HTTP/2 and QUIC which *could* be a nice speed boost, depending on a lot of factors * **warning:** nginx-QUIC (HTTP/3) is still experimental and can make uploads much slower, so HTTP/1.1 is recommended for now * depending on server/client, HTTP/1.1 can also be 5x faster than HTTP/2 diff --git a/contrib/nginx/copyparty.conf b/contrib/nginx/copyparty.conf index 6e762bb7..92efb756 100644 --- a/contrib/nginx/copyparty.conf +++ b/contrib/nginx/copyparty.conf @@ -1,14 +1,10 @@ -# when running copyparty behind a reverse proxy, -# the following arguments are recommended: -# -# -i 127.0.0.1 only accept connections from nginx -# -# -nc must match or exceed the webserver's max number of concurrent clients; -# copyparty default is 1024 if OS permits it (see "max clients:" on startup), +# look for "max clients:" when starting copyparty, as nginx should +# not accept more consecutive clients than what copyparty is able to; # nginx default is 512 (worker_processes 1, worker_connections 512) # -# you may also consider adding -j0 for CPU-intensive configurations -# (5'000 requests per second, or 20gbps upload/download in parallel) +# rarely, in some extreme usecases, it can be good to add -j0 +# (40'000 requests per second, or 20gbps upload/download in parallel) +# but this is usually counterproductive and slightly buggy # # on fedora/rhel, remember to setsebool -P httpd_can_network_connect 1 # @@ -20,10 +16,33 @@ # # and then enable it below by uncomenting the cloudflare-only.conf line -upstream cpp { + +upstream cpp_tcp { + # alternative 1: connect to copyparty using tcp; + # cpp_uds is slightly faster and more secure, but + # cpp_tcp is easier to setup and "just works" + # ...you should however restrict copyparty to only + # accept connections from nginx by adding these args: + # -i 127.0.0.1 + server 127.0.0.1:3923 fail_timeout=1s; keepalive 1; } + + +upstream cpp_uds { + # alternative 2: unix-socket, aka. "unix domain socket"; + # 5-10% faster, and better isolation from other software, + # but there must be at least one unix-group which both + # nginx and copyparty is a member of; if that group is + # "www" then run copyparty with the following args: + # -i unix:770:www:/tmp/party.sock + + server unix:/tmp/party.sock fail_timeout=1s; + keepalive 1; +} + + server { listen 443 ssl; listen [::]:443 ssl; @@ -34,7 +53,8 @@ server { #include /etc/nginx/cloudflare-only.conf; location / { - proxy_pass http://cpp; + # recommendation: replace cpp_tcp with cpp_uds below + proxy_pass http://cpp_tcp; proxy_redirect off; # disable buffering (next 4 lines) proxy_http_version 1.1; @@ -52,6 +72,7 @@ server { } } + # default client_max_body_size (1M) blocks uploads larger than 256 MiB client_max_body_size 1024M; client_header_timeout 610m; diff --git a/docs/notes.sh b/docs/notes.sh index 7c659092..a50abf3b 100644 --- a/docs/notes.sh +++ b/docs/notes.sh @@ -255,6 +255,9 @@ cat copyparty/httpcli.py | awk '/^[^a-zA-Z0-9]+def / {printf "%s\n%s\n\n", f, pl # create a folder with symlinks to big files for d in /usr /var; do find $d -type f -size +30M 2>/dev/null; done | while IFS= read -r x; do ln -s "$x" big/; done +# up2k worst-case testfiles: create 64 GiB (256 x 256 MiB) of sparse files; each file takes 1 MiB disk space; each 1 MiB chunk is globally unique +for f in {0..255}; do echo $f; truncate -s 256M $f; b1=$(printf '%02x' $f); for o in {0..255}; do b2=$(printf '%02x' $o); printf "\x$b1\x$b2" | dd of=$f bs=2 seek=$((o*1024*1024)) conv=notrunc 2>/dev/null; done; done + # py2 on osx brew install python@2 pip install virtualenv diff --git a/docs/rice/README.md b/docs/rice/README.md index d602a45c..ab94f04e 100644 --- a/docs/rice/README.md +++ b/docs/rice/README.md @@ -63,6 +63,8 @@ add your own translations by using the english or norwegian one from `browser.js the easy way is to open up and modify `browser.js` in your own installation; depending on how you installed copyparty it might be named `browser.js.gz` instead, in which case just decompress it, restart copyparty, and start editing it anyways +you will be delighted to see inline html in the translation strings; to help prevent syntax errors, there is [a very jank linux script](https://github.com/9001/copyparty/blob/hovudstraum/scripts/tlcheck.sh) which is slightly better than nothing -- just beware the false-positives, so even if it complains it's not necessarily wrong/bad + if you're running `copyparty-sfx.py` then you'll find it at `/tmp/pe-copyparty.1000/copyparty/web` (on linux) or `%TEMP%\pe-copyparty\copyparty\web` (on windows) * make sure to keep backups of your work religiously! since that location is volatile af