cyrus 发表于 2018-6-23 10:41:03

Nginx在windows下的使用尝试

  Nginx在windows下的使用
  下载 nginx-1.6.0,解压到任意Ipanema目录即可
  1.配置:
  在/conf/添加 代理 和解压缩 配置(proxy.conf ,gzip.conf)
  proxy.conf 内容:
  proxy_redirect off;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  client_max_body_size 10m;
  client_body_buffer_size 128k;
  proxy_connect_timeout 300;
  proxy_send_timeout 300;
  proxy_read_timeout 300;
  proxy_buffer_size 4k;
  proxy_buffers 4 32k;
  proxy_busy_buffers_size 64k;
  proxy_temp_file_write_size 64k;
  gzip.conf 内容:
  gzip            on;
  gzip_min_length   1024;
  gzip_buffers      4 8k;
  gzip_comp_level   9;
  gzip_proxied      any;
  gzip_types      application/xml application/javascript application/x-javascript application/atom+xml application/rss+xml;
  gzip_types      text/csstext/javascript text/js text/plain text/xml;
  *在gzip_types 默认适配text/html 可不加,如果在此处报错,***掉text/html即可。
  2.在/conf/nginx.conf 下,修改文件。
  把proxy.conf ,gzip.conf添加进来
  http{
  ... ...
  include    gzip.conf;
  include    proxy.conf;
  #添加一些设置
  client_header_timeout3m;
  client_body_timeout    3m;
  send_timeout         3m;
  client_header_buffer_size    1k;
  large_client_header_buffers4 4k;
  ... ...
  }
  3.一台服务器,多个tomcat的切换
  http{
  ......
  upstream localhost {
  #weigth参数表示权值,权值越高被分配到的几率越大
  server localhost:28080 weight=1;
  server localhost:18080 weight=2;
  ...
  }
  ......
  Server{
  listen       80;
  server_namewww.xxxcom;#本地可以监测localhost
  index index.jsp index.htm index.do index.action;
  rootXXX; #web的工作目录
  #charset koi8-r;
  #access_loglogs/host.access.logmain;
  location / {
  rootxxx;
  indexindex.html index.jsp;
  }
  }
  }
  本地开启多个tomcat,使用默认的配置即可。
  在nginx文件下cmd   start nginx开启进程即可
  Nginx -s stop关闭
  4.一个服务器,多个站点的去端口访问
  配置两个server{} 在http{}里面
  server_name 填写网站名称
  Index 访问的主页名称index.html index.htm index.jsp...
  root 站点目录地址
  重启nginx即可访问。
页: [1]
查看完整版本: Nginx在windows下的使用尝试