Skip to content

Commit 9cb93ae

Browse files
committed
fix upload into share with vproxy; closes #168
1 parent e3e51fb commit 9cb93ae

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

contrib/nginx/copyparty.conf

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,38 @@
22
# not accept more consecutive clients than what copyparty is able to;
33
# nginx default is 512 (worker_processes 1, worker_connections 512)
44
#
5+
# ======================================================================
6+
#
7+
# to reverse-proxy a specific path/subpath/location below a domain
8+
# (rather than a complete subdomain), for example "/qw/er", you must
9+
# run copyparty with --rp-loc /qw/as and also change the following:
10+
# location / {
11+
# proxy_pass http://cpp_tcp;
12+
# to this:
13+
# location /qw/er/ {
14+
# proxy_pass http://cpp_tcp/qw/er/;
15+
#
16+
# ======================================================================
17+
#
518
# rarely, in some extreme usecases, it can be good to add -j0
619
# (40'000 requests per second, or 20gbps upload/download in parallel)
720
# but this is usually counterproductive and slightly buggy
821
#
22+
# ======================================================================
23+
#
924
# on fedora/rhel, remember to setsebool -P httpd_can_network_connect 1
1025
#
11-
# if you are behind cloudflare (or another protection service),
26+
# ======================================================================
27+
#
28+
# if you are behind cloudflare (or another CDN/WAF/protection service),
1229
# remember to reject all connections which are not coming from your
1330
# protection service -- for cloudflare in particular, you can
1431
# generate the list of permitted IP ranges like so:
1532
# (curl -s https://www.cloudflare.com/ips-v{4,6} | sed 's/^/allow /; s/$/;/'; echo; echo "deny all;") > /etc/nginx/cloudflare-only.conf
1633
#
1734
# and then enable it below by uncomenting the cloudflare-only.conf line
35+
#
36+
# ======================================================================
1837

1938

2039
upstream cpp_tcp {

copyparty/httpcli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,10 +2587,6 @@ def handle_post_json(self) -> bool:
25872587
x = self.conn.hsrv.broker.ask("up2k.handle_json", body, self.u2fh.aps)
25882588
ret = x.get()
25892589

2590-
if self.is_vproxied:
2591-
if "purl" in ret:
2592-
ret["purl"] = self.args.SR + ret["purl"]
2593-
25942590
if self.args.shr and self.vpath.startswith(self.args.shr1):
25952591
# strip common suffix (uploader's folder structure)
25962592
vp_req, vp_vfs = vroots(self.vpath, vjoin(dbv.vpath, vrem))
@@ -2600,6 +2596,10 @@ def handle_post_json(self) -> bool:
26002596
raise Pebkac(500, t % zt)
26012597
ret["purl"] = vp_req + ret["purl"][len(vp_vfs) :]
26022598

2599+
if self.is_vproxied:
2600+
if "purl" in ret:
2601+
ret["purl"] = self.args.SR + ret["purl"]
2602+
26032603
ret = json.dumps(ret)
26042604
self.log(ret)
26052605
self.reply(ret.encode("utf-8"), mime="application/json")

0 commit comments

Comments
 (0)