nginx负载均衡 #《实例:负载均衡》#$time_iso8601 ISO8601标准格式下的本地时间 2017-08-30T09:16:15+08:00。#user nobody;worker_processes 1; #工作的子进程数量(通常等于CPU数量或者2倍于CPU) #error_log
#《实例:负载均衡》 #$time_iso8601 ISO8601标准格式下的本地时间 2017-08-30T09:16:15+08:00。 #user nobody; worker_processes 1; #工作的子进程数量(通常等于CPU数量或者2倍于CPU) #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; #默认文件类型 #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 $request $time_local $request_body $http_referer $http_user_agent' # '$upstream_http_x_uuid $upstream_http_host $http_[HEADER_NAME] $http_search_engines $msec'; #$query_string 请求 URI中的参数,与 $args相同 #$args HTTP 请求中的完整参数。 #$request_uri 表示客户端发来的原始请求URI,带完整的参数。$uri和$document_uri未必是用户的原始请求,在内部重定向后可能是重定向后的URI, # 而$request_uri 永远不会改变,始终是客户端的原始URI. #$uri 表示当前请求的URI,不带任何参数 #$host 表示客户端请求头部中的Host字段。如果Host字段不存在,则以实际处理的server(虚拟主机)名称代替。如果Host字段中带有端口,如IP:PORT,那么$host是去掉端口的, # 它的值为IP。$host 是全小写的。这些特性与http_HEADER中的http_host不同,http_host只取出Host头部对应的值。 #$http_cookie $X-Forwarded-For #配置格式main的log================================================================================= log_format main '$remote_addr $time_local $http_user_agent $http_referer $args $http_x_forwarded_for'; #使用格式为main的log access_log logs/access.log main; #配置格式main的log================================================================================= #log_format up_head '$remote_addr [$time_local] $request $upstream_http_content_type'; #access_log logs/access.log up_head; sendfile on; #开启高效文件传输模式 #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #长连接超时时间,单位是秒 gzip on; #启用Gizp压缩 #limit_conn_zone $binary_remote_addr zone=perip:1m; #limit_conn_zone $server_name zone=perserver:1m; #服务器的集群(负载均衡:tomcat) https://my.oschina.net/u/2246410/blog/618798 #netitcast.com 集群名称 #upstream netitcast.com { #server 127.0.0.1:80 weight=2; #服务器配置 #server 127.0.0.1:28080 weight=1; # } server { client_max_body_size 4G; listen 8081; #监听80端口,可以改成其他端口 server_name localhost; #当前服务的域名 #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location ~ .*\.(bmp|swf|css|js)$ { root html; access_log off; expires 0s; } location ~ .*\.(gif|jpg|jpeg|png)$ { root html; expires 0s; } set $uid "-"; if ( $http_cookie ~* "uid=(\S+)(;.*|$)"){ set $uid $1; } #集群负载均衡 #location / { # proxy_pass http://netitcast.com; # proxy_redirect default; # } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # 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-知识点.docx nginx-知识点.docx 高并发设计.pptx 高并发设计.pptx