development 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. include /etc/nginx/conf.d/server_config;
  2. upstream web {
  3. server web:8000;
  4. }
  5. server {
  6. access_log /var/log/nginx/access.log cache_log;
  7. listen 80;
  8. sendfile on;
  9. tcp_nopush on;
  10. tcp_nodelay on;
  11. keepalive_timeout 65;
  12. types_hash_max_size 2048;
  13. #include /etc/nginx/mime.types;
  14. #default_type application/octet-stream;
  15. gzip on;
  16. gzip_disable "msie6";
  17. proxy_read_timeout 1800s;
  18. chunked_transfer_encoding on;
  19. # store responses to anonymous users for up to 1 minute
  20. proxy_cache bookwyrm_cache;
  21. proxy_cache_valid any 1m;
  22. add_header X-Cache-Status $upstream_cache_status;
  23. # ignore the set cookie header when deciding to
  24. # store a response in the cache
  25. proxy_ignore_headers Cache-Control Set-Cookie Expires;
  26. # PUT requests always bypass the cache
  27. # logged in sessions also do not populate the cache
  28. # to avoid serving personal data to anonymous users
  29. proxy_cache_methods GET HEAD;
  30. proxy_no_cache $cookie_sessionid;
  31. proxy_cache_bypass $cookie_sessionid;
  32. # tell the web container the address of the outside client
  33. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  34. proxy_set_header Host $host;
  35. proxy_redirect off;
  36. # rate limit the login or password reset pages
  37. location ~ ^/(login[^-/]|password-reset|resend-link|2fa-check) {
  38. limit_req zone=loginlimit;
  39. proxy_pass http://web;
  40. }
  41. # do not log periodic polling requests from logged in users
  42. location /api/updates/ {
  43. access_log off;
  44. proxy_pass http://web;
  45. }
  46. # forward any cache misses or bypass to the web container
  47. location / {
  48. proxy_pass http://web;
  49. }
  50. # directly serve images and static files from the
  51. # bookwyrm filesystem using sendfile.
  52. # make the logs quieter by not reporting these requests
  53. location ~ ^/(images|static)/ {
  54. root /app;
  55. try_files $uri =404;
  56. add_header X-Cache-Status STATIC;
  57. access_log off;
  58. }
  59. # monitor the celery queues with flower, no caching enabled
  60. location /flower/ {
  61. proxy_pass http://flower:8888;
  62. proxy_cache_bypass 1;
  63. }
  64. }