nginx.conf 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # /etc/nginx/nginx.conf
  2. user nginx;
  3. # Set number of worker processes automatically based on number of CPU cores.
  4. worker_processes auto;
  5. # Enables the use of JIT for regular expressions to speed-up their processing.
  6. pcre_jit on;
  7. # Configures default error logger.
  8. error_log /var/log/nginx/error.log warn;
  9. # Includes files with directives to load dynamic modules.
  10. include /etc/nginx/modules/*.conf;
  11. events {
  12. # The maximum number of simultaneous connections that can be opened by
  13. # a worker process.
  14. worker_connections 1024;
  15. }
  16. http {
  17. # Includes mapping of file name extensions to MIME types of responses
  18. # and defines the default type.
  19. include /etc/nginx/mime.types;
  20. default_type application/octet-stream;
  21. # Name servers used to resolve names of upstream servers into addresses.
  22. # It's also needed when using tcpsocket and udpsocket in Lua modules.
  23. #resolver 208.67.222.222 208.67.220.220;
  24. # Don't tell nginx version to clients.
  25. server_tokens off;
  26. # Specifies the maximum accepted body size of a client request, as
  27. # indicated by the request header Content-Length. If the stated content
  28. # length is greater than this size, then the client receives the HTTP
  29. # error code 413. Set to 0 to disable.
  30. client_max_body_size 200m;
  31. # Timeout for keep-alive connections. Server will close connections after
  32. # this time.
  33. keepalive_timeout 65;
  34. # Sendfile copies data between one FD and other from within the kernel,
  35. # which is more efficient than read() + write().
  36. sendfile on;
  37. # Don't buffer data-sends (disable Nagle algorithm).
  38. # Good for sending frequent small bursts of data in real time.
  39. tcp_nodelay on;
  40. # Causes nginx to attempt to send its HTTP response head in one packet,
  41. # instead of using partial frames.
  42. #tcp_nopush on;
  43. # Path of the file with Diffie-Hellman parameters for EDH ciphers.
  44. #ssl_dhparam /etc/ssl/nginx/dh2048.pem;
  45. # Specifies that our cipher suits should be preferred over client ciphers.
  46. ssl_prefer_server_ciphers on;
  47. # Enables a shared SSL cache with size that can hold around 8000 sessions.
  48. ssl_session_cache shared:SSL:2m;
  49. # Enable gzipping of responses.
  50. gzip on;
  51. # Set the Vary HTTP header as defined in the RFC 2616.
  52. gzip_vary on;
  53. # Enable checking the existence of precompressed files.
  54. # gzip_static on;
  55. gzip_min_length 1k;
  56. gzip_buffers 16 64k;
  57. gzip_http_version 1.1;
  58. gzip_comp_level 5;
  59. gzip_proxied any;
  60. gzip_types text/plain application/x-javascript application/javascript application/octet-stream text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png image/svg image/svg+xml;
  61. # Specifies the main log format.
  62. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  63. '$status $body_bytes_sent "$http_referer" '
  64. '"$http_user_agent" "$http_x_forwarded_for"';
  65. # Sets the path, format, and configuration for a buffered log write.
  66. access_log /var/log/nginx/access.log main;
  67. # Includes virtual hosts configs.
  68. include /etc/nginx/conf.d/*.conf;
  69. server {
  70. listen 9000;
  71. server_name localhost;
  72. rewrite /apps /finchat-publish-website last;
  73. location ^~ /api/ {
  74. proxy_redirect off;
  75. proxy_set_header Host $host;
  76. proxy_set_header X-Real-IP $remote_addr;
  77. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  78. proxy_pass http://127.0.0.1:5000;
  79. }
  80. location ~* /(.*)/static {
  81. root /web/static;
  82. try_files $uri $uri/ 404;
  83. }
  84. location ~* /(.*)/(.*)\.(js|css|ico) {
  85. root /web/static;
  86. try_files $uri $uri/ 404;
  87. }
  88. location ~* /(.*)\.zip$ {
  89. # kill cache
  90. add_header Last-Modified $date_gmt;
  91. add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  92. if_modified_since off;
  93. expires off;
  94. etag off;
  95. root /web/static;
  96. try_files $uri $uri/ 404;
  97. }
  98. location ~* /(.*)/(.*) {
  99. # kill cache
  100. add_header Last-Modified $date_gmt;
  101. add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  102. if_modified_since off;
  103. expires off;
  104. etag off;
  105. root /web/static/$1/;
  106. try_files $uri $uri/ /$2.html /index.html =404;
  107. }
  108. location ~* /(.*) {
  109. # kill cache
  110. add_header Last-Modified $date_gmt;
  111. add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  112. if_modified_since off;
  113. expires off;
  114. etag off;
  115. root /web/static/$1/;
  116. try_files $uri $uri/ /index.html =404;
  117. }
  118. }
  119. }
  120. daemon off;