nginx.conf 1002 B

123456789101112131415161718192021222324252627282930313233343536
  1. server {
  2. listen 80;
  3. listen [::]:80;
  4. server_name localhost;
  5. gzip on;
  6. gzip_static on;
  7. gzip_comp_level 6;
  8. gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  9. location / {
  10. root /usr/share/nginx/html;
  11. #index index.html;
  12. try_files $uri $uri/ /index.html;
  13. # 显式允许所有HTTP方法
  14. if ($request_method !~ ^(GET|HEAD|POST|PUT|DELETE|PATCH|OPTIONS)$ ) {
  15. return 405;
  16. }
  17. client_max_body_size 300m; #最大接受300m文件以内的
  18. client_body_timeout 20s;
  19. }
  20. location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css){
  21. root /usr/share/nginx/html;
  22. expires 7d;
  23. }
  24. #error_page 404 /404.html;
  25. # redirect server error pages to the static page /50x.html
  26. #
  27. error_page 500 502 503 504 /50x.html;
  28. location = /50x.html {
  29. root /usr/share/nginx/html;
  30. }
  31. }