GitHub Asset Acceleration (github)
Overview
The github mode turns Pavonis into a reverse proxy for GitHub file downloads, accelerating access to various GitHub resources. It is ideal for environments where direct access to GitHub is restricted.
Upstream hosts and paths proxied:
| Host | Supported Paths |
|---|---|
github.com | Release assets (releases/download/, releases/latest/download/), source archives (archive/), raw files (raw/), file pages (blob/, served as the raw file content), git clone / fetch / push, git LFS |
raw.githubusercontent.com | Raw file content |
gist.github.com | Gist raw files (raw), gist archives (archive/, download), git clone / push |
gist.githubusercontent.com | Gist raw files (raw) |
Paths not listed above, such as repository home pages, release pages and issues, return 404. Git LFS objects are not accelerated: the client still downloads them directly from GitHub, and only the lookup requests go through Pavonis.
When accessing a private repository or pushing, git prompts for GitHub credentials, which Pavonis forwards to GitHub. Pushing and git LFS lock operations return 403 unless allow_push is enabled.
Request Format
Client request paths follow the format:
/{GitHub URL (scheme optional)}If the upstream URL scheme is omitted, Pavonis uses https:
https://gh.example.com/https://github.com/user/repo/releases/download/v1.0/app.tar.gz
https://gh.example.com/github.com/user/repo/releases/download/v1.0/app.tar.gzFor example, if the github site is bound to gh.example.com:
# Download a GitHub Release asset
https://gh.example.com/https://github.com/user/repo/releases/download/v1.0/app.tar.gz
# Access a Raw file
https://gh.example.com/https://raw.githubusercontent.com/user/repo/main/README.md
# Clone a repository
git clone https://gh.example.com/https://github.com/user/repo.gitSettings
Corresponding Go config type:
GithubSiteSettings
| Field | Type | Default | Description |
|---|---|---|---|
size_limit | int | 0 | Maximum size in bytes, applied to the request body and the response body separately. 0 means unlimited. Larger requests or responses are refused, or cut off mid-transfer when the size is not known in advance |
raw_text_url_rewrite | bool | false | Whether to rewrite GitHub URLs found inside Raw text file content so they point to this proxy. Requires self_url when enabled |
allow_push | bool | false | Whether to allow git push and git LFS lock operations |
repos_whitelist | []string | [] | Repository allowlist. Requests for repos not on the list return 403 |
repos_blacklist | []string | [] | Repository denylist. Requests for repos on the list return 403 |
Allow/Deny List Format
Each entry is in the form owner/repo, with * wildcards supported:
repos_whitelist:
- 'torvalds/linux' # exact match
- 'torvalds/*' # all repos under torvalds
- '*/linux' # all repos named linuxWhen both lists are configured, a repository must be on the allowlist and not on the denylist for the request to pass.
Matching is case-insensitive, and a repository name with or without the .git suffix refers to the same repository.
Gists are matched by owner only, so list entries for gists must be written as owner/*. The default clone URL shown on gist pages, https://gist.github.com/{gist ID}.git, does not contain the owner, so it is rejected with 403 when either list is configured. Clone with https://gist.github.com/{owner}/{gist ID}.git instead.
Configuration Examples
Basic Usage
sites:
- id: ghproxy
host: gh.example.com
mode: githubLimit Transfer Size
sites:
- id: ghproxy
host: gh.example.com
mode: github
settings:
size_limit: 104857600 # 100 MiBEnable Raw Text URL Rewriting
When enabled, Pavonis rewrites the GitHub URLs supported by this proxy (see the hosts and paths in the Overview) in a file from raw.githubusercontent.com or gist.githubusercontent.com when the upstream response's Content-Type is text/plain and explicitly declares a UTF-8 charset, so they go through this proxy. Downloads the client then makes based on the file content still pass through this proxy.
For example, a client downloads an install script through the proxy:
curl -fsSL https://gh.example.com/https://raw.githubusercontent.com/user/repo/main/install.shThe script's content on GitHub is as follows. The line that downloads setup.conf points to raw.githubusercontent.com:
#!/bin/sh
set -e
echo "Installing example tool..."
curl -fsSL https://raw.githubusercontent.com/user/repo/main/setup.conf -o setup.conf
mkdir -p /etc/example
mv setup.conf /etc/example/
echo "Done."When disabled, the client receives exactly this script. When it reaches the setup.conf download, it connects to GitHub directly and fails on networks where GitHub is unreachable.
When enabled, in the script the client receives, that download URL has been rewritten to go through this proxy:
#!/bin/sh
set -e
echo "Installing example tool..."
curl -fsSL https://gh.example.com/https://raw.githubusercontent.com/user/repo/main/setup.conf -o setup.conf
mkdir -p /etc/example
mv setup.conf /etc/example/
echo "Done."This way users do not need to edit the download URLs in the script by hand, and no separate copy of the script has to be maintained on GitHub for the proxy.
Rewriting modifies the file content, so it is not suitable for files whose hash or signature is verified.
When this option is enabled, all files from raw.githubusercontent.com and gist.githubusercontent.com are always downloaded in full, so resumable and range downloads do not work.
sites:
- id: ghproxy
host: gh.example.com
mode: github
self_url: https://gh.example.com
settings:
raw_text_url_rewrite: trueConfigure an Allowlist
sites:
- id: ghproxy
host: gh.example.com
mode: github
settings:
repos_whitelist:
- 'my-org/*'
- 'trusted-user/specific-repo'