console_nginx.template 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # This is a separate mzimage so that we don't have to re-install the apt things
  10. # every time we get a CI builder with a cold cache.
  11. # Package a pinned version of the console into the image, for ease of getting
  12. # started with Materialize. It's okay if this console lags a bit behind what's
  13. # deployed to production, but the version needs to be bumped whenever features
  14. # that the console depends upon are removed (to a version of the console that
  15. # doesn't depend on those features).
  16. server {
  17. ${MZ_NGINX_LISTENER_CONFIG}
  18. server_name _;
  19. location / {
  20. root /usr/share/nginx/html;
  21. index index.html;
  22. try_files $uri $uri/ /index.html;
  23. }
  24. location /api {
  25. client_max_body_size 100M;
  26. proxy_connect_timeout 600s;
  27. proxy_send_timeout 600s;
  28. proxy_read_timeout 600s;
  29. # WebSocket support
  30. proxy_set_header Upgrade $http_upgrade;
  31. proxy_set_header Connection "upgrade";
  32. proxy_http_version 1.1;
  33. proxy_request_buffering on;
  34. proxy_buffers 16 32k;
  35. proxy_buffer_size 64k;
  36. proxy_busy_buffers_size 128k;
  37. proxy_temp_file_write_size 128k;
  38. proxy_pass ${MZ_ENDPOINT};
  39. proxy_set_header Host $host;
  40. proxy_set_header X-Real-IP $remote_addr;
  41. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  42. proxy_set_header X-Forwarded-Proto $scheme;
  43. proxy_set_header X-Request-ID $request_id;
  44. proxy_set_header X-Webhook-Event $http_x_webhook_event;
  45. }
  46. # Cache policy for static assets
  47. location ~* \.(js|css|png|jpg|jpeg|gif|svg|woff|woff2)$ {
  48. root /usr/share/nginx/html;
  49. try_files $uri =404;
  50. expires 1y;
  51. add_header Cache-Control "public, max-age=31536000, immutable";
  52. }
  53. # Gzip compression
  54. gzip on;
  55. gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
  56. gzip_min_length 256;
  57. gzip_comp_level 6;
  58. gzip_vary on;
  59. gzip_proxied any;
  60. gzip_buffers 16 8k;
  61. error_page 404 /404.html;
  62. }