nginx.conf 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 'Allow' 'GET,HEAD';
  32. return 204;
  33. }
  34. alias /var/clsi/tiny.pdf;
  35. }
  36. location ~ ^/project/0([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.pdf$ {
  37. if ($request_method = 'OPTIONS') {
  38. # handle OPTIONS method for CORS requests
  39. add_header 'Allow' 'GET,HEAD';
  40. return 204;
  41. }
  42. alias /var/clsi/tiny.pdf;
  43. }
  44. # handle output files for specific users
  45. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.([a-z.]+)$ {
  46. if ($request_method = 'OPTIONS') {
  47. # handle OPTIONS method for CORS requests
  48. add_header 'Allow' 'GET,HEAD';
  49. return 204;
  50. }
  51. alias /output/$1-$2/generated-files/$3/output.$4;
  52. }
  53. # handle .blg files for specific users
  54. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)\.blg$ {
  55. if ($request_method = 'OPTIONS') {
  56. # handle OPTIONS method for CORS requests
  57. add_header 'Allow' 'GET,HEAD';
  58. return 204;
  59. }
  60. alias /output/$1-$2/generated-files/$3/$4.blg;
  61. }
  62. # handle output files for anonymous users
  63. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.([a-z.]+)$ {
  64. if ($request_method = 'OPTIONS') {
  65. # handle OPTIONS method for CORS requests
  66. add_header 'Allow' 'GET,HEAD';
  67. return 204;
  68. }
  69. alias /output/$1/generated-files/$2/output.$3;
  70. }
  71. # handle .blg files for anonymous users
  72. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)\.blg$ {
  73. if ($request_method = 'OPTIONS') {
  74. # handle OPTIONS method for CORS requests
  75. add_header 'Allow' 'GET,HEAD';
  76. return 204;
  77. }
  78. alias /output/$1/generated-files/$2/$3.blg;
  79. }
  80. # PDF range for specific users
  81. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  82. if ($request_method = 'OPTIONS') {
  83. # handle OPTIONS method for CORS requests
  84. add_header 'Allow' 'GET,HEAD';
  85. return 204;
  86. }
  87. # Cache for one day
  88. expires 1d;
  89. alias /output/$1-$2/content/$3;
  90. }
  91. # PDF range for anonymous users
  92. location ~ ^/project/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  93. if ($request_method = 'OPTIONS') {
  94. # handle OPTIONS method for CORS requests
  95. add_header 'Allow' 'GET,HEAD';
  96. return 204;
  97. }
  98. # Cache for one day
  99. expires 1d;
  100. alias /output/$1/content/$2;
  101. }
  102. # status endpoint for haproxy httpchk option
  103. location /status {
  104. return 200;
  105. }
  106. # load shedding probe
  107. location = /instance-state {
  108. alias /var/clsi/instance-state;
  109. }
  110. }