clsi-nginx.conf 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # keep in sync with services/clsi/nginx.conf
  2. # Changes to the above:
  3. # - added Security-Headers
  4. # - remove CORS rules, Server-CE/Server-Pro runs behind a single origin
  5. # - change /output path to /var/lib/overleaf/data/output
  6. # - remove tiny.pdf endpoints
  7. server {
  8. add_header 'X-Served-By' 'clsi-nginx' always;
  9. # Security-Headers
  10. add_header 'X-Content-Type-Options' 'nosniff' always;
  11. add_header 'X-Download-Options' 'noopen' always;
  12. add_header 'X-Frame-Options' 'SAMEORIGIN' always;
  13. add_header 'X-XSS-Protection' '1; mode=block' always;
  14. listen 8080;
  15. server_name clsi-nginx;
  16. server_tokens off;
  17. access_log off;
  18. # Ignore symlinks possibly created by users
  19. disable_symlinks on;
  20. # enable compression for tex auxiliary files, but not for pdf files
  21. gzip on;
  22. gzip_types text/plain;
  23. gzip_proxied any;
  24. types {
  25. text/plain log blg aux stdout stderr;
  26. application/pdf pdf;
  27. }
  28. # handle output files for specific users
  29. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ {
  30. rewrite ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ /$4 break;
  31. root /var/lib/overleaf/data/output/$1-$2/generated-files/$3/;
  32. }
  33. # handle output files for anonymous users
  34. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ {
  35. rewrite ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ /$3 break;
  36. root /var/lib/overleaf/data/output/$1/generated-files/$2/;
  37. }
  38. # PDF range for specific users
  39. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  40. # Cache for one day
  41. expires 1d;
  42. alias /var/lib/overleaf/data/output/$1-$2/content/$3;
  43. }
  44. # PDF range for anonymous users
  45. location ~ ^/project/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  46. # Cache for one day
  47. expires 1d;
  48. alias /var/lib/overleaf/data/output/$1/content/$2;
  49. }
  50. # Do not look up any non matching files in the default root.
  51. location / {
  52. return 404;
  53. }
  54. }