nginx.conf 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #user nobody;
  2. user root;
  3. worker_processes 4;
  4. error_log /data/logs/error.log;
  5. #error_log logs/error.log notice;
  6. #error_log logs/error.log info;
  7. #pid logs/nginx.pid;
  8. events {
  9. worker_connections 1024;
  10. }
  11. http {
  12. include mime.types;
  13. default_type application/octet-stream;
  14. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  15. '$status $body_bytes_sent "$http_referer" '
  16. '"$http_user_agent" "$http_x_forwarded_for"';
  17. access_log /data/logs/access.log main;
  18. sendfile on;
  19. #tcp_nopush on;
  20. #keepalive_timeout 0;
  21. #keepalive_timeout 65;
  22. gzip on; # 开启gzip
  23. gzip_disable "msie6"; #IE6 不适用gzip
  24. gzip_vary on; # 设置为on 会在Header里增加 ”Vary:Accept-Encodng“
  25. gzip_proxied any;# 代理数据结果得压缩
  26. gzip_comp_level 6; # gzip压缩比( 1-9 ),越小压缩效果越差,但是越大处理效果越慢,所以一般取中间值
  27. gzip_buffers 18 8k; # 获取多少内存用于缓存压缩结果
  28. gzip_http_version 1.1; # 识别http协议版本
  29. gzip_min_length 1k; #设置允许压缩得页面最小字节数,超过1k得文件会被压缩
  30. gzip_types application/javascipt text/css; # 对特定得MIME类型生效,js和css文件会被压缩
  31. include /usr/local/nginx/vhosts/*;
  32. server {
  33. listen 80;
  34. server_name localhost;
  35. #charset koi8-r;
  36. #access_log logs/host.access.log main;
  37. location / {
  38. root html;
  39. index index.html index.htm;
  40. }
  41. location /images/ {
  42. add_header Access-Control-Allow-Origin *;
  43. root /data/material/;
  44. autoindex on;
  45. }
  46. #error_page 404 /404.html;
  47. # redirect server error pages to the static page /50x.html
  48. #
  49. error_page 500 502 503 504 /50x.html;
  50. location = /50x.html {
  51. root html;
  52. }
  53. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  54. #
  55. #location ~ \.php$ {
  56. # proxy_pass http://127.0.0.1;
  57. #}
  58. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  59. #
  60. #location ~ \.php$ {
  61. # root html;
  62. # fastcgi_pass 127.0.0.1:9000;
  63. # fastcgi_index index.php;
  64. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  65. # include fastcgi_params;
  66. #}
  67. # deny access to .htaccess files, if Apache's document root
  68. # concurs with nginx's one
  69. #
  70. #location ~ /\.ht {
  71. # deny all;
  72. #}
  73. }
  74. # another virtual host using mix of IP-, name-, and port-based configuration
  75. #
  76. #server {
  77. # listen 8000;
  78. # listen somename:8080;
  79. # server_name somename alias another.alias;
  80. # location / {
  81. # root html;
  82. # index index.html index.htm;
  83. # }
  84. #}
  85. # HTTPS server
  86. #
  87. #server {
  88. # listen 443 ssl;
  89. # server_name localhost;
  90. # ssl_certificate cert.pem;
  91. # ssl_certificate_key cert.key;
  92. # ssl_session_cache shared:SSL:1m;
  93. # ssl_session_timeout 5m;
  94. # ssl_ciphers HIGH:!aNULL:!MD5;
  95. # ssl_prefer_server_ciphers on;
  96. # location / {
  97. # root html;
  98. # index index.html index.htm;
  99. # }
  100. #}
  101. }