nginx.conf 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # keep in sync with clsi-startup.sh files
  2. server {
  3. # Extra header for dev-env.
  4. add_header 'X-Served-By' 'clsi-nginx' always;
  5. listen 8080;
  6. server_name clsi-proxy;
  7. server_tokens off;
  8. access_log off;
  9. # Ignore symlinks possibly created by users
  10. disable_symlinks on;
  11. # enable compression for tex auxiliary files, but not for pdf files
  12. gzip on;
  13. gzip_types text/plain;
  14. gzip_proxied any;
  15. types {
  16. text/plain log blg aux stdout stderr;
  17. application/pdf pdf;
  18. }
  19. # handle output files for specific users
  20. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.([a-z]+)$ {
  21. if ($request_method = 'OPTIONS') {
  22. # handle OPTIONS method for CORS requests
  23. add_header 'Allow' 'GET,HEAD';
  24. return 204;
  25. }
  26. alias /output/$1-$2/generated-files/$3/output.$4;
  27. }
  28. # handle output files for anonymous users
  29. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.([a-z]+)$ {
  30. if ($request_method = 'OPTIONS') {
  31. # handle OPTIONS method for CORS requests
  32. add_header 'Content-Type' 'text/plain charset=UTF-8';
  33. add_header 'Allow' 'GET,HEAD';
  34. return 200 'GET,HEAD';
  35. }
  36. alias /output/$1/generated-files/$2/output.$3;
  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. if ($request_method = 'OPTIONS') {
  41. # handle OPTIONS method for CORS requests
  42. add_header 'Content-Type' 'text/plain charset=UTF-8';
  43. add_header 'Allow' 'GET,HEAD';
  44. return 200 'GET,HEAD';
  45. }
  46. # Cache for one day
  47. expires 1d;
  48. alias /output/$1-$2/content/$3;
  49. }
  50. # PDF range for anonymous users
  51. location ~ ^/project/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  52. if ($request_method = 'OPTIONS') {
  53. # handle OPTIONS method for CORS requests
  54. add_header 'Content-Type' 'text/plain charset=UTF-8';
  55. add_header 'Allow' 'GET,HEAD';
  56. return 200 'GET,HEAD';
  57. }
  58. # Cache for one day
  59. expires 1d;
  60. alias /output/$1/content/$2;
  61. }
  62. # status endpoint for haproxy httpchk option
  63. location /status {
  64. return 200;
  65. }
  66. # load shedding probe
  67. location = /instance-state {
  68. alias /var/clsi/instance-state;
  69. }
  70. }