nginx http配置指令
Devin hao Architect

  设定mime类型,类型由mime.type文件定义 用include指令.

include       /etc/nginx/mime.types;
default_type  application/octet-stream;

  开启gzip压缩指令

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

  设定负载均衡的服务器列表用指令upstream

upstream mysvr {
    #weigth参数表示权值,权值越高被分配到的几率越大
    #本机上的Squid开启3128端口
    server 192.168.8.1:3128 weight=5;
    server 192.168.8.2:80  weight=1;
    server 192.168.8.3:80  weight=6;
}

  设定虚拟主机用指令server,其中包括端口,主机名称,默认请求等设置。

server {
    #侦听80端口
    listen       80;
    #定义使用www.xx.com访问
    server_name  www.xx.com;
    #设定本虚拟主机的访问日志
    access_log  logs/www.xx.com.access.log  main;
    #默认请求
    location / {
          root   /root;      #定义服务器的默认网站根目录位置
          index index.php index.html index.htm;   #定义首页索引文件的名称
          fastcgi_pass  www.xx.com;
          fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
          include /etc/nginx/fastcgi_params;
     }

    # 定义错误提示页面
    error_page   500 502 503 504 /50x.html; 
    location = /50x.html {
    root   /root;
    }
}

请求转向指令_proxypass

proxy_pass http://www.baidu.com;