ngix的配置

#设置用户
#user  nobody;
#工作进程数
worker_processes  1;
#设置错误文件存放路径
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#设置pid存放路径(pid是控制系统中重要文件)
#pid        logs/nginx.pid;

#设置最大连接数
events {
#并发响应能力的关键配置
#每个进程允许的最大同时连接数,work_connectins*worker_processes = maxConnection;
#要注意maxConnections不等同于可响应的用户数量。
#因为一般一个浏览器会同时开两条链接,如果反向代理,nginx到后端服务器的链接也要占用链接数。
#所以,做静态服务器时,一般maxClient =work_connectins*worker_processes/2
#做反向代理服务器时,maxClient = work_connectins * worker_processes /4;
#user epoll  指明使用epoll或kquene
    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"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    ##上传文件最大600m
    client_max_body_size 600m;
    ## upstream待选服务器列表
    upstream hwsicmserver{
    ##  ip_hash  绑定同一个用户的请求   weight=1服务器的权重
    ip_hash;
     #  server 192.168.1.112:8080 weight=1;
		 server 119.90.51.183:9162 weight=1;
    }
	##
	upstream hwsicsserver{
        #server 119.90.51.183:9184  weight=1;
		server 192.168.1.15:8080  weight=1;
		 server 119.90.51.183:9162  weight=1;
    }
	##Upstream模块实现在轮询和客户端ip之间实现后端的负载均衡。常用的
	##ip_hash指令,server指令,和upstream指令等。
	##
	
    upstream moganshanserver{
	server 119.90.51.183:9189 weight=1;
    }

    server {
        listen       8001;
        server_name  localhost;

        #反向代理时候,设置nginx将域名携带到tomcat服务器  
        proxy_set_header   Host    $host;
        proxy_set_header   Remote_Addr    $remote_addr;
        proxy_set_header   X-Real-IP    $remote_addr;
        proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #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;
        }
	##
        location /mogan {
            proxy_pass   http://moganserver/mogan;
            add_header Cache-Control 'no-store';
        }

		 ##
        location ~ /hwsicsweb/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf)$ {
            root   D:\Xi;
            index  index.html index.htm;
            add_header Cache-Control 'no-store';
        }
		
		##
        location /hwsics {
            proxy_pass   http://hwsicsserver/hwsics;
            add_header Cache-Control 'no-store';
        }
	
	##
        location ~ /hicdweb/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf)$ {
            root   D:\Xi;
            index  index.html index.htm;
            add_header Cache-Control 'no-store';
        }
		
		##
        location /hicd {
            proxy_pass   http://hicdserver/hicd;
            add_header Cache-Control 'no-store';
        }
		
		 ##
	    location ~ /moganweb/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf)$ {
            root   D:\Xi;
            index  index.html index.htm;
            add_header Cache-Control 'no-store';
        }
		
	 ##
        location ~ /hwsicmweb/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf)$ {
            root   D:\Xi;
            index  index.html index.htm;
            add_header Cache-Control 'no-store';
        }
        
	    location /hwsicm {
            proxy_pass   http://hwsicmserver/hwsicm;
            add_header Cache-Control 'no-store';
        }
		
		##
        location ~ /moganshanweb/.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf|json|swf|ttf|woff|xlsx)$ {
            root   D:\Xi; 
            index  index.html index.htm;
            add_header Cache-Control 'no-store';
        }
		
		  ##api- 莫干山会议系统  
        location /moganshan {
            proxy_pass  http://moganshanserver/moganshan;
            add_header Cache-Control 'no-store';
        }

        # proxy the PHP scripts to Apache listening on 119.90.51.183:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://119.90.51.183;
        #}

        # pass the PHP scripts to FastCGI server listening on 119.90.51.183:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   119.90.51.183: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;
    #    }
    #}

}

阻塞和非阻塞网络模型:
同步阻塞模型:一请求一进(线)程,当进(线)程增加到一定程度后。
更多cpu时间浪费到切换一,性能急剧下降,所以负载率不高。
Nginx基于事件的非阻塞多路复用模型(epoll或kquene).
一个进程在短时间内可以响应大量的请求。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值