Skip to main content

Overview

Running copyparty behind a reverse proxy provides several benefits:
  • Automatic HTTPS/TLS certificate management
  • HTTP/2 and HTTP/3 support
  • Better isolation and security
  • Host multiple services on the same ports (80/443)
  • Load balancing and caching capabilities
Proper configuration of client IP detection is critical. Without it, all requests will appear to come from the proxy, breaking rate limiting and bans.

Configuration Methods

You can deploy copyparty behind a reverse proxy in two ways: Dedicate a subdomain to copyparty:
  • https://files.example.com → copyparty
  • Simpler configuration
  • Better performance
  • Fewer edge cases

Path-Based Proxying

Mount copyparty under a path:
  • https://example.com/files → copyparty
  • Requires --rp-loc /files argument
  • Slight performance cost
  • More complex setup

Client IP Detection

Copyparty needs to know the real client IP for rate limiting, bans, and logging.
1

Configure your reverse proxy

Ensure your proxy sends the correct header:
  • Most proxies: X-Forwarded-For
  • Cloudflare: CF-Connecting-IP
  • Custom: Any header name you configure
2

Configure copyparty

Tell copyparty which header to trust:
Header contains single IP (most cases):
Header contains multiple IPs (CDN chain):
If you see “thank you for playing” messages, your IP detection is misconfigured and the proxy itself is getting banned.

nginx Configuration

Recommended for best performance and compatibility.

Subdomain Setup

1

Start copyparty with unix socket

Using unix sockets is 5-10% faster and more secure:
Or with TCP:
2

Create nginx configuration

Create /etc/nginx/conf.d/copyparty.conf:
3

Configure copyparty

4

SELinux (Fedora/RHEL)

Allow nginx to connect:
5

Test and reload

Path-Based Setup

For mounting copyparty at a subpath like /files:
And start copyparty with:

Cloudflare + nginx

If using Cloudflare in front of nginx:
1

Restrict to Cloudflare IPs

Generate and include Cloudflare IP allowlist:
2

Update nginx config

3

Configure copyparty

Apache Configuration

1

Enable required modules

2

Create virtual host

Create /etc/apache2/sites-available/copyparty.conf:
3

Enable site

4

SELinux (Fedora/RHEL)

Caddy Configuration

Caddy automatically handles HTTPS certificates via Let’s Encrypt.

Subdomain Setup

Path-Based Setup

Start copyparty with --rp-loc /files.

Command-Line Usage

Cloudflare Tunnel

For quick deployment without exposing ports or managing certificates:
1

Install cloudflared

2

Quick tunnel (temporary URL)

Cloudflare will assign a random URL like https://random-words.trycloudflare.com.
3

Permanent tunnel (custom domain)

  1. Go to Cloudflare Dashboard → Zero Trust → Networks → Tunnels
  2. Create a tunnel → Cloudflared
  3. Choose subdomain (e.g., files.example.com)
  4. Service type: HTTP, URL: 127.0.0.1:3923
  5. Copy and run the provided command
4

Configure copyparty for Cloudflare

Cloudflare Tunnels work well with CGNAT and restrictive firewalls since they establish outbound connections.

Performance Comparison

Benchmark results using unix sockets:
Unix sockets provide 5-10% better performance than TCP connections.

Troubleshooting

Incorrect —rp-loc Error

Error: incorrect --rp-loc or webserver config; expected vpath starting with [...] Cause: Proxy is stripping the location prefix from URLs. Solution: Ensure the proxy passes the full path:

Thumbnails Return 404

Cause: Proxy strips query parameters (?th=w). Solution: Check proxy cache settings and URL rewrite rules.

Getting Banned Immediately

Cause: Client IP detection is wrong, proxy IP is getting banned. Solution:
  1. Check copyparty logs for helpful messages
  2. Verify --xff-hdr, --xff-src, and --rproxy settings
  3. See docs/xff.md

502 Bad Gateway

Causes:
  1. Copyparty isn’t running
  2. Wrong socket/port configuration
  3. Permissions issue with unix socket
Solutions:

Upload Fails with Large Files

Cause: Proxy timeout or size limits. Solution:

SSL/TLS Best Practices

Let’s Encrypt with Certbot

Manual SSL Configuration

For nginx:

Next Steps

Security Hardening

Harden your reverse proxy setup

Docker Deployment

Run behind proxy in Docker

Systemd Service

Configure systemd service