1
0

nginx.conf 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #user nobody;
  2. worker_processes 1;
  3. #error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;
  6. #pid logs/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. types {
  14. application/javascript js mjs;
  15. text/css css;
  16. text/html html;
  17. }
  18. sendfile on;
  19. # tcp_nopush on;
  20. #keepalive_timeout 0;
  21. # keepalive_timeout 65;
  22. # gzip on;
  23. # gzip_buffers 32 16k;
  24. # gzip_comp_level 6;
  25. # gzip_min_length 1k;
  26. # gzip_static on;
  27. # gzip_types text/plain
  28. # text/css
  29. # application/javascript
  30. # application/json
  31. # application/x-javascript
  32. # text/xml
  33. # application/xml
  34. # application/xml+rss
  35. # text/javascript; #设置压缩的文件类型
  36. # gzip_vary on;
  37. server {
  38. listen 8080;
  39. server_name localhost;
  40. location / {
  41. root /usr/share/nginx/html;
  42. try_files $uri $uri/ /index.html;
  43. index index.html;
  44. # Enable CORS
  45. add_header 'Access-Control-Allow-Origin' '*';
  46. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  47. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  48. if ($request_method = 'OPTIONS') {
  49. add_header 'Access-Control-Max-Age' 1728000;
  50. add_header 'Content-Type' 'text/plain charset=UTF-8';
  51. add_header 'Content-Length' 0;
  52. return 204;
  53. }
  54. }
  55. error_page 500 502 503 504 /50x.html;
  56. location = /50x.html {
  57. root /usr/share/nginx/html;
  58. }
  59. }
  60. }
  61. # stream { # stream 模块配置和 http 模块在相同级别
  62. # upstream redis {
  63. # server 127.0.0.1:6379 max_fails=3 fail_timeout=30s;
  64. # }
  65. # server {
  66. # listen 16379;
  67. # proxy_connect_timeout 1s;
  68. # proxy_timeout 3s;
  69. # proxy_pass redis;
  70. # }
  71. # }