nginx.conf 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # keep in sync with server-ce/nginx/clsi-nginx.conf
  2. server {
  3. add_header 'X-Served-By' 'clsi-nginx' always;
  4. listen 8080;
  5. server_name clsi-nginx;
  6. server_tokens off;
  7. access_log off;
  8. # Ignore symlinks possibly created by users
  9. disable_symlinks on;
  10. # enable compression for tex auxiliary files, but not for pdf files
  11. gzip on;
  12. gzip_types text/plain;
  13. gzip_proxied any;
  14. types {
  15. text/plain log blg aux stdout stderr;
  16. application/pdf pdf;
  17. }
  18. # user content domain access check
  19. location ~ ^/project/0cba050a0cec68384666fad1/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/output\.pdf$ {
  20. if ($request_method = 'OPTIONS') {
  21. # handle OPTIONS method for CORS requests
  22. add_header 'Allow' 'GET,HEAD';
  23. return 204;
  24. }
  25. alias /var/clsi/tiny.pdf;
  26. }
  27. location ~ ^/project/0cba050a0cec68384666fad1/build/([0-9a-f-]+)/output/output\.pdf$ {
  28. if ($request_method = 'OPTIONS') {
  29. # handle OPTIONS method for CORS requests
  30. add_header 'Allow' 'GET,HEAD';
  31. return 204;
  32. }
  33. alias /var/clsi/tiny.pdf;
  34. }
  35. # handle output files for specific users
  36. location ~ ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ {
  37. if ($request_method = 'OPTIONS') {
  38. # handle OPTIONS method for CORS requests
  39. add_header 'Allow' 'GET,HEAD';
  40. return 204;
  41. }
  42. rewrite ^/project/([0-9a-f]+)/user/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ /$4 break;
  43. root /output/$1-$2/generated-files/$3/;
  44. }
  45. # handle output files for anonymous users
  46. location ~ ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ {
  47. if ($request_method = 'OPTIONS') {
  48. # handle OPTIONS method for CORS requests
  49. add_header 'Allow' 'GET,HEAD';
  50. return 204;
  51. }
  52. rewrite ^/project/([0-9a-f]+)/build/([0-9a-f-]+)/output/(.+)$ /$3 break;
  53. root /output/$1/generated-files/$2/;
  54. }
  55. # handle output files for submissions
  56. location ~ ^/project/([a-zA-Z0-9_-]+)/build/([0-9a-f-]+)/output/(.+)$ {
  57. if ($request_method = 'OPTIONS') {
  58. # handle OPTIONS method for CORS requests
  59. add_header 'Allow' 'GET,HEAD';
  60. return 204;
  61. }
  62. rewrite ^/project/([a-zA-Z0-9_-]+)/build/([0-9a-f-]+)/output/(.+)$ /$3 break;
  63. root /output/$1/generated-files/$2/;
  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 'Allow' 'GET,HEAD';
  70. return 204;
  71. }
  72. # Cache for one day
  73. expires 1d;
  74. alias /output/$1-$2/content/$3;
  75. }
  76. # PDF range for anonymous users
  77. location ~ ^/project/([0-9a-f]+)/content/([0-9a-f-]+/[0-9a-f]+)$ {
  78. if ($request_method = 'OPTIONS') {
  79. # handle OPTIONS method for CORS requests
  80. add_header 'Allow' 'GET,HEAD';
  81. return 204;
  82. }
  83. # Cache for one day
  84. expires 1d;
  85. alias /output/$1/content/$2;
  86. }
  87. # status endpoint for haproxy httpchk option
  88. location /status {
  89. return 200;
  90. }
  91. # load shedding probe
  92. location = /instance-state {
  93. alias /var/clsi/instance-state;
  94. }
  95. # Do not look up any non matching files in the default root.
  96. location / {
  97. return 404;
  98. }
  99. }