A media files proxy worker for Misskey.
- Set your config items via environment variables in the ".env"
- Run
npm run deploy
to deploy your worker.
or you can run npm run build
to build the worker without deploying, and deploy it manually.
-
More secure than the official one, can reduce the abusing.
-
Integrated cache and polish.
Please use the environment variable to configure the proxy, you can configure them at Cloudflare's dashboard or in the wrangler.toml
file.
[vars]
ALLOW_ORIGIN = "https://pwp.space"
PROXY_USER_AGENT = ""
THIRD_PARTY_CLIENTS_USER_AGENT = ""
VALIDATE_PATHNAME = true
VALIDATE_SIGN = false
VALIDATE_REFERER = false
RETURN_EMPTY_PIC_WHEN_ERROR = false
BLACK_LIST_DOMAIN = ""
STRIP_VIA_FOR_USER_AGENTS = ""
BLOCKED_VIA_PSEUDO_NAMES = ["misskey/media-proxy-worker"]
To set the PROXY_KEY
, you can use the wrangler secret put
command.
wrangler secret put PROXY_KEY [YOUR_PROXY_KEY]
ALLOW_ORIGIN
: The allowed origin for CORS requestsPROXY_USER_AGENT
: The User-Agent header to use when proxying requestsTHIRD_PARTY_CLIENTS_USER_AGENT
: Array of User-Agent strings for third-party clientsVALIDATE_PATHNAME
: Whether to validate the pathname starts with '/proxy'VALIDATE_SIGN
: Whether to validate request signaturesVALIDATE_REFERER
: Whether to validate the referer headerVALIDATE_USER_AGENT
: Whether to validate the User-Agent headerRETURN_EMPTY_PIC_WHEN_ERROR
: Whether to return an empty image on errorBLACK_LIST_DOMAIN
: Array of blocked domainsCACHE_MAX_AGE
: Maximum cache age in secondsCF_POLISH
: Cloudflare Polish setting ('lossy', 'lossless', or 'off')EXTRA_PROXY_HEADERS
: JSON object of additional headers to add to proxied requestsTRANSPARENT_PROXY
: JSON object for transparent proxy configurationTRANSPARENT_PROXY_MODE
: Mode for transparent proxy ('path' or 'query')TRANSPARENT_PROXY_QUERY
: Query parameter name for transparent proxySTRIP_VIA_FOR_USER_AGENTS
: Array of User-Agent strings to strip Via header forBLOCKED_VIA_PSEUDO_NAMES
: Array of blocked Via header pseudo namesPASS_USER_AGENT_FROM_REQUEST
: Whether to pass the User-Agent header from the request to the remote target
See this issue for more details:
MIT