rekopub.monoexp.com.conf 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # /etc/nginx/vhosts.d/rekopub.monoexp.com.conf
  2. #
  3. # ReKoPub's website and downloads, published by the deploy pipeline
  4. # (bajdev/devops, kind "cli") on every merge into bajdev/ReKoPub main.
  5. # The converter form's requests (/api/) and the books it makes (/books/) go
  6. # to rekopub-web (goapp@rekopub-web, 127.0.0.1:8004), which runs the
  7. # rekopub command. Port 80 (ACME challenges and the HTTP->HTTPS redirect)
  8. # is handled by the `.monoexp.com` block in 00-default.conf.
  9. # A first line of defence for the converter: per client address, at most
  10. # 6 conversion requests a minute, with a burst of 5. rekopub-web has the
  11. # real limits (50 for everyone and 10 per visitor in 15 minutes).
  12. limit_req_zone $binary_remote_addr zone=rekopub_convert:1m rate=6r/m;
  13. limit_req_zone $binary_remote_addr zone=rekopub_api:1m rate=60r/m;
  14. server {
  15. listen 443 ssl; listen [::]:443 ssl;
  16. server_name rekopub.monoexp.com;
  17. ssl_certificate /etc/letsencrypt/live/rekopub.monoexp.com/fullchain.pem;
  18. ssl_certificate_key /etc/letsencrypt/live/rekopub.monoexp.com/privkey.pem;
  19. include snippets/tls-common.conf;
  20. root /srv/www/vhosts/rekopub.monoexp.com;
  21. index index.html;
  22. location / { try_files $uri $uri/ =404; }
  23. # The download names stay the same from one version to the next, so
  24. # browsers must check for a newer file every time.
  25. location /download/ { expires -1; }
  26. # Short cache for the stylesheet, script and icon; HTML keeps nginx's
  27. # defaults.
  28. location ~* \.(css|js|svg)$ { expires 1h; }
  29. # The converter. The form is a few hundred bytes; a conversion can take
  30. # a few minutes (two runs of up to 2 minutes each for "Both", plus up to
  31. # a minute waiting for a free slot).
  32. location = /api/convert {
  33. limit_req zone=rekopub_convert burst=5 nodelay;
  34. limit_req_status 429;
  35. client_max_body_size 8k;
  36. proxy_read_timeout 330s;
  37. include snippets/proxy.conf;
  38. proxy_pass http://127.0.0.1:8004;
  39. }
  40. location = /api/status {
  41. limit_req zone=rekopub_api burst=20 nodelay;
  42. limit_req_status 429;
  43. include snippets/proxy.conf;
  44. proxy_pass http://127.0.0.1:8004;
  45. }
  46. location /api/ { return 404; }
  47. # Finished books: random 128-bit folder names, deleted after 24 hours.
  48. location /books/ {
  49. limit_req zone=rekopub_api burst=20 nodelay;
  50. limit_req_status 429;
  51. include snippets/proxy.conf;
  52. proxy_pass http://127.0.0.1:8004;
  53. }
  54. }