1.HTTP核心模块
A. client_body_buffer_size:指定连接请求实体的缓冲区大小,如果超了,那么这些请求实体的整体或部分将尝试写入一个临时文件,默认值是8k/16K;
B. client_body_temp_path:指定连接请求实体试图写入的临时文件路径,默认值是client_body_temp;
C. client_max_body_size:指定允许客户端连接的最大请求实体大小,如果超了,返回客户端“Request Entity Too Large” 413错误,默认值是1m;
2. HTTP代理模块
A. proxy_pass:设置被代理服务器的地址和被映射的URI,地址可以使用主机名或IP加端口号的形式,默认值是no,使用字段在location或location中if字段;
B. proxy_set_header:允许将发送到被代理服务器的请求头重新定义或增加一些字段,默认值是Host and Connection,使用字段在http,server,location;
C. proxy_connect_timeout:指定一个连接到代理服务器的超时时间,默认值是60s,使用字段在http,server,location;
D. proxy_send_timeout:设置代理服务器转发请求的超时时间,如果超了,nginx将关闭连接,默认值是60s,使用字段在http,server,location;
E.proxy_read_timeout:设置读取后端服务器应答的超时时间,默认值是60s,使用字段在http,server,location。
3. nginx.conf 配置文件
#user  nobody;
worker_processes  1;
# 错误日志
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    
    # 开启HTTPS
    ssl on;
    
    # 为这个虚拟主机指定PEM格式的证书文件,注意windows下绝对路径有问题 
    ssl_certificate server.crt;
    
    # 为这个虚拟主机指定PEM格式的秘钥,注意windows下绝对路径有问题 
    ssl_certificate_key server.key;
    
    # 指定要使用的SSL协议
    ssl_protocols SSLv2 SSLv3 TLSv1;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
    # 日志格式
    log_format  main '["$remote_addr","$http_x_forwarded_for","$request","$request_body","$status","$body_bytes_sent","$bytes_sent","$msec","$http_user_agent","$request_length","$request_time","$upstream_response_time","$time_local","$upstream_addr"]'
    
    # 访问日志
    #access_log  logs/access.log  main;
    
    # 使用sendfile系统调用来传递文件
    sendfile        on;
    #tcp_nopush     on;
    
    # 指定客户端与服务器长连接的超时时间,超时将关闭连接
    keepalive_timeout  65;
    #gzip  on;
    
    # 设置一群服务器,提供负载均衡
    upstream address {
        # 指定后端服务器的名称和一些参数,可以使用域名,IP,端口,其中weight指权重
        server localhost:8083 weight=1;
        server localhost:8084 weight=1;
        server localhost:8085 weight=1;
    }
    
    # 包含虚拟主机的配置
    server {
        # 被访问的ip地址及端口号,可以只指定一个IP,一个端口,或者一个可解析的服务器名
        listen 4202;
        
        # 将HTTP请求的主机头与这指定的参数进行匹配
        server_name localhost;
        
        # 指定连接请求实体的缓冲区大小,如果超过,那么请求实体的整体或部分将尝试写入一个临时文件
        client_body_buffer_size 256K;
        
        # 指定连接请求实体试图写入的临时文件路径
        # client_body_temp_path client_body_temp;
        
        # 匹配查询,根据URI的不同需求来进行配置
        location / {
            # 请求达到后文件的根目录
            root dist;
            
            # 如果URL中没有指定文件。则设置一个默认主页
            index index.html;
        }
        
        location /manage {
            # 指定允许客户端连接的最大请求实体大小(文件上传需要增大,默认1m)
            client_max_body_size 500m;
            
            # 设置被代理服务器的地址和被映射的URI,地址可以使用主机名或IP加端口号的形式(最后面斜杠必须写)
            proxy_pass  http://localhost:8082/;
            
            # 设置代理服务器转发请求的超时时间,超时nginx将关闭(默认是60s)
            proxy_send_timeout 240;
            
            # 读取后端服务器应答的超时时间(默认是60s)
            proxy_read_timeout 240;
        }
        
        location /business {
            client_max_body_size 100m;
            proxy_pass  http://localhost:8081/;
            proxy_send_timeout 240;
            proxy_read_timeout 240;
        }
        
        location /oauth {
            proxy_pass  http://localhost:9001/;
        }
        
        location /address {
            proxy_pass http://address;
        }
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}
可参考:Nginx中文手册
 
  
  
  
 
 
  
 
 
 