Skip to content

pikpak: add proxy_url option for download acceleration#9124

Open
nickhoo555 wants to merge 1 commit intorclone:masterfrom
nickhoo555:feature/pikpak-proxy-url
Open

pikpak: add proxy_url option for download acceleration#9124
nickhoo555 wants to merge 1 commit intorclone:masterfrom
nickhoo555:feature/pikpak-proxy-url

Conversation

@nickhoo555
Copy link

Summary

Add a new configuration option proxy_url for the PikPak backend that allows users to specify a reverse proxy URL for accelerating downloads.

Problem

Some users experience slow direct download speeds from PikPak servers due to network conditions or geographic location.

Solution

When proxy_url is configured, download URLs are routed through the specified proxy.

Usage

Via command line, config file, or environment variable RCLONE_PIKPAK_PROXY_URL.

Testing

Tested with Cloudflare Worker reverse proxy, confirmed working with significant speed improvement.

Add a new configuration option 'proxy_url' that allows users to specify
a Cloudflare Worker (or similar) reverse proxy URL for accelerating
downloads from PikPak.

When configured, download URLs will be routed through the proxy:
https://proxy.example.com/https://original-download-url

This is useful for users who experience slow direct download speeds
from PikPak servers.
Copy link
Member

@ncw ncw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok to me.

Are you happy with this @wiserain ?

@wiserain
Copy link
Contributor

URL format seems to be specific for certain method. Can I ask which tool you used for proxy?

@nickhoo555
Copy link
Author

I used a Cloudflare Worker as the reverse proxy. Here's the basic Worker code:

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  // Extract the target URL from the path (e.g., /https://example.com/file)
  let url = request.url.substr(8)
  url = decodeURIComponent(url.substr(url.indexOf('/') + 1))
  
  if (url.indexOf('://') === -1) {
    url = 'https://' + url
  }

  // Forward the request with original headers
  const headers = new Headers(request.headers)
  headers.delete('host')
  
  const response = await fetch(url, {
    method: request.method,
    headers: headers,
    body: request.body
  })

  return new Response(response.body, {
    status: response.status,
    headers: response.headers
  })
}

The proxy URL format https://proxy.example.com/https://original-url is a common pattern used by many CF Worker proxies. This format is simple and widely adopted.

If there are other popular proxy URL formats that should be supported, I'm happy to add them as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants