Skip to content

Self-hosting › Reverse proxy

Reverse proxy

web listens on 127.0.0.1:3000 on the host (WEB_BIND / WEB_PORT in .env to change it). Put the reverse proxy of your choice in front of it.

What the proxy must do

  • terminate HTTPS for your domain, ideally with HSTS (Strict-Transport-Security);
  • forward the original Host header;
  • set X-Forwarded-For to the client IP. Sign-in rate limits are per IP, so a proxy that sends its own IP for everyone makes all users share one limit. spellcache reads the last entry of the header, the one your proxy writes: replace the header (as below) rather than append to a value the client sent;
  • not cache HTML responses.

AUTH_URL must be the public HTTPS URL users type in their browser.

Examples

server {
listen 443 ssl http2;
server_name spellcache.example.com;
# ssl_certificate / ssl_certificate_key …
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

Public share pages

Do not put basic auth or an access filter in front of the whole site. The public share pages (/s/<id>) must stay readable without an account: Scryfall’s terms forbid putting card data behind authentication or a paywall.