Skip to content

Run a public PixivFE instance ​

A public instance is PixivFE on a server, behind a reverse proxy that adds HTTPS.

You need:

1. Start PixivFE ​

sh
git clone https://gitlab.com/pixivfe/PixivFE.git
cd PixivFE/deploy
cp .env.example .env

Edit .env:

sh
PIXIVFE_HOST="0.0.0.0"
PIXIVFE_TOKEN="token1,token2,token3"

Start it:

sh
docker compose up -d

PixivFE 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:

sh
sudo cp pixiv-media.caddy /etc/caddy/

Then put this in /etc/caddy/Caddyfile, with your domain:

caddy
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 Host header.
  • Don't remove Origin or Sec-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 what pixiv-media.caddy does. Forward only Range, If-Range, If-None-Match and If-Modified-Since from the visitor's request, and set Referer: https://www.pixiv.net/. Visitors' cookies hold their pixiv sessions, and their other headers identify them. Add its Content-Security-Policy and X-Content-Type-Options to 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 ​

sh
cd PixivFE/deploy
git pull
docker compose pull
docker compose up -d
sudo cp pixiv-media.caddy /etc/caddy/
sudo systemctl reload caddy

Limit memory ​

Go programs use more memory when they can. To cap it, add to the pixivfe service in compose.yaml:

yaml
    mem_limit: 2000m
    environment:
      GOMEMLIMIT: 1800m

Images ​

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.