nginx.conf 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 .blg files for specific users
  56. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)\.blg$ {
  57. if ($request_method = 'OPTIONS') {
  58. # handle OPTIONS method for CORS requests
  59. add_header 'Allow' 'GET,HEAD';
  60. return 204;
  61. }
  62. alias /output/$1-$2/generated-files/$3/$4.blg;
  63. }
  64. # handle output files for anonymous users
  65. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.([a-z]+)$ {
  66. if ($request_method = 'OPTIONS') {
  67. # handle OPTIONS method for CORS requests
  68. add_header 'Content-Type' 'text/plain charset=UTF-8';
  69. add_header 'Allow' 'GET,HEAD';
  70. return 200 'GET,HEAD';
  71. }
  72. alias /output/$1/generated-files/$2/output.$3;
  73. }
  74. # handle .blg files for anonymous users
  75. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)\.blg$ {
  76. if ($request_method = 'OPTIONS') {
  77. # handle OPTIONS method for CORS requests
  78. add_header 'Allow' 'GET,HEAD';
  79. return 204;
  80. }
  81. alias /output/$1/generated-files/$2/$3.blg;
  82. }
  83. # PDF range for specific users
  84. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  85. if ($request_method = 'OPTIONS') {
  86. # handle OPTIONS method for CORS requests
  87. add_header 'Content-Type' 'text/plain charset=UTF-8';
  88. add_header 'Allow' 'GET,HEAD';
  89. return 200 'GET,HEAD';
  90. }
  91. # Cache for one day
  92. expires 1d;
  93. alias /output/$1-$2/content/$3;
  94. }
  95. # PDF range for anonymous users
  96. location ~ ^/project/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  97. if ($request_method = 'OPTIONS') {
  98. # handle OPTIONS method for CORS requests
  99. add_header 'Content-Type' 'text/plain charset=UTF-8';
  100. add_header 'Allow' 'GET,HEAD';
  101. return 200 'GET,HEAD';
  102. }
  103. # Cache for one day
  104. expires 1d;
  105. alias /output/$1/content/$2;
  106. }
  107. # status endpoint for haproxy httpchk option
  108. location /status {
  109. return 200;
  110. }
  111. # load shedding probe
  112. location = /instance-state {
  113. alias /var/clsi/instance-state;
  114. }
  115. }