Run a public PixivFE instance
A public instance is PixivFE on a server, behind a reverse proxy that adds HTTPS.
You need:
- A server with Docker and the Compose plugin
- A domain pointing at the server
- pixiv tokens, ideally from several spare accounts (see why)
1. Start PixivFE
git clone https://gitlab.com/pixivfe/PixivFE.git
cd PixivFE/deploy
cp .env.example .envEdit .env:
PIXIVFE_HOST="0.0.0.0"
PIXIVFE_TOKEN="token1,token2,token3"Start it:
docker compose up -dPixivFE now listens on 127.0.0.1:8282, reachable only from the server.
2. Add HTTPS
Install Caddy and copy the media configuration next to its Caddyfile:
sudo cp pixiv-media.caddy /etc/caddy/Then put this in /etc/caddy/Caddyfile, with your domain:
import pixiv-media.caddy
pixivfe.example.com {
import pixivfe_media
reverse_proxy localhost:8282
}Reload Caddy: sudo systemctl reload caddy. Caddy gets the HTTPS certificate itself.
import pixivfe_media makes Caddy fetch images and animations from pixiv itself, so that traffic does not pass through PixivFE. Without it, PixivFE proxies them, which works but puts every image download through PixivFE as well. pixiv-media.caddy explains what it forwards.
Other reverse proxies work too. Whichever you use:
- Keep the original
Hostheader. - Don't remove
OriginorSec-Fetch-Site. PixivFE uses them to block cross-site form posts, and answers HTTP 403 without them. - If you serve the
/proxy/paths yourself, do whatpixiv-media.caddydoes. Forward onlyRange,If-Range,If-None-MatchandIf-Modified-Sincefrom the visitor's request, and setReferer: https://www.pixiv.net/. Visitors' cookies hold their pixiv sessions, and their other headers identify them. Add itsContent-Security-PolicyandX-Content-Type-Optionsto the responses, so a proxied file cannot run scripts on your domain.
3. Protect it
Public instances attract bots, which consume pixiv API requests. Put anti-bot protection at your reverse proxy, for example caddy-turnstile or Anubis.
Use several accounts
pixiv may suspend an account that sends too many requests. With several tokens, PixivFE spreads requests across them and keeps working if one gets blocked.
Use spare accounts, not your own: the Discovery page shows content based on the account's preferences.
Update
cd PixivFE/deploy
git pull
docker compose pull
docker compose up -d
sudo cp pixiv-media.caddy /etc/caddy/
sudo systemctl reload caddyLimit memory
Go programs use more memory when they can. To cap it, add to the pixivfe service in compose.yaml:
mem_limit: 2000m
environment:
GOMEMLIMIT: 1800mImages
With the Caddyfile above, Caddy fetches images on the same server. To move that traffic to another server, host an image proxy or use a public one.
Get listed
Once your instance has run for a week, ask to add it to the instance list.