nginx.conf 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # keep in sync with clsi-startup.sh files
  2. # keep in sync with server-ce/nginx/clsi-nginx.conf
  3. # Changes to the above:
  4. # - added debug header
  5. server {
  6. # Extra header for dev-env.
  7. add_header 'X-Served-By' 'clsi-nginx' always;
  8. listen 8080;
  9. server_name clsi-proxy;
  10. server_tokens off;
  11. access_log off;
  12. # Ignore symlinks possibly created by users
  13. disable_symlinks on;
  14. # enable compression for tex auxiliary files, but not for pdf files
  15. gzip on;
  16. gzip_types text/plain;
  17. gzip_proxied any;
  18. types {
  19. text/plain log blg aux stdout stderr;
  20. application/pdf pdf;
  21. }
  22. # user content domain access check
  23. # The project-id is zero prefixed. No actual user project uses these ids.
  24. # mongo-id 000000000000000000000000 -> 1970-01-01T00:00:00.000Z
  25. # mongo-id 000000010000000000000000 -> 1970-01-01T00:00:01.000Z
  26. # mongo-id 100000000000000000000000 -> 1978-07-04T21:24:16.000Z
  27. # This allows us to distinguish between check-traffic and regular output traffic.
  28. location ~ ^/project/0([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.pdf$ {
  29. if ($request_method = 'OPTIONS') {
  30. # handle OPTIONS method for CORS requests
  31. add_header 'Content-Type' 'text/plain charset=UTF-8';
  32. add_header 'Allow' 'GET,HEAD';
  33. return 200 'GET,HEAD';
  34. }
  35. alias /var/clsi/tiny.pdf;
  36. }
  37. location ~ ^/project/0([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.pdf$ {
  38. if ($request_method = 'OPTIONS') {
  39. # handle OPTIONS method for CORS requests
  40. add_header 'Content-Type' 'text/plain charset=UTF-8';
  41. add_header 'Allow' 'GET,HEAD';
  42. return 200 'GET,HEAD';
  43. }
  44. alias /var/clsi/tiny.pdf;
  45. }
  46. # handle output files for specific users
  47. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.([a-z]+)$ {
  48. if ($request_method = 'OPTIONS') {
  49. # handle OPTIONS method for CORS requests
  50. add_header 'Allow' 'GET,HEAD';
  51. return 204;
  52. }
  53. alias /output/$1-$2/generated-files/$3/output.$4;
  54. }
  55. # handle output files for anonymous users
  56. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.([a-z]+)$ {
  57. if ($request_method = 'OPTIONS') {
  58. # handle OPTIONS method for CORS requests
  59. add_header 'Content-Type' 'text/plain charset=UTF-8';
  60. add_header 'Allow' 'GET,HEAD';
  61. return 200 'GET,HEAD';
  62. }
  63. alias /output/$1/generated-files/$2/output.$3;
  64. }
  65. # PDF range for specific users
  66. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  67. if ($request_method = 'OPTIONS') {
  68. # handle OPTIONS method for CORS requests
  69. add_header 'Content-Type' 'text/plain charset=UTF-8';
  70. add_header 'Allow' 'GET,HEAD';
  71. return 200 'GET,HEAD';
  72. }
  73. # Cache for one day
  74. expires 1d;
  75. alias /output/$1-$2/content/$3;
  76. }
  77. # PDF range for anonymous users
  78. location ~ ^/project/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  79. if ($request_method = 'OPTIONS') {
  80. # handle OPTIONS method for CORS requests
  81. add_header 'Content-Type' 'text/plain charset=UTF-8';
  82. add_header 'Allow' 'GET,HEAD';
  83. return 200 'GET,HEAD';
  84. }
  85. # Cache for one day
  86. expires 1d;
  87. alias /output/$1/content/$2;
  88. }
  89. # status endpoint for haproxy httpchk option
  90. location /status {
  91. return 200;
  92. }
  93. # load shedding probe
  94. location = /instance-state {
  95. alias /var/clsi/instance-state;
  96. }
  97. }