zoukankan      html  css  js  c++  java
  • nginx.conf

    #定义nginx运行的用户和用户组
    #user  nobody;
    
    #nginx进程数,通常设置为cpu个数
    worker_processes  1;
    
    #全局错误日志定义类型
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #进程pid文件
    #pid        logs/nginx.pid;
    
    #指定进程可以打开的最大描述符 数目(打开文件数/进程数)
    #如果填写10240,总并发达到3万-4万时就有进程可以超过10240,这时会返回502 error
    #worker_rlimit_nofile 65535;
    
    
    events {
        #单个进程最大连接数(连接数+进程)
        worker_connections  1024;
    }
    
    #设定http服务器
    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指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,
        #如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
        sendfile        on;
    
        #此选项允许或禁止使用socke的TCP_CORK的选项,此选项仅在使用sendfile的时候使用
        #tcp_nopush     on;
        
        #超时时间,单位s
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip模块设置
        gzip on; #开启gzip压缩输出
        gzip_min_length 1k;    #最小压缩文件大小
        gzip_buffers 4 16k;    #压缩缓冲区
        gzip_http_version 1.0; #压缩版本(默认1.1,前端如果是squid2.5请使用1.0)
        gzip_comp_level 2;     #压缩等级
        #压缩类型,默认就已经包含textml,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
        gzip_types text/plain application/x-javascript text/css application/xml;    
        gzip_vary on;
    
        #负载均衡设置
        upstream blog {
            #upstream的负载均衡,weight是权重,可以根据机器配置定义权重。weigth参数表示权值,权值越高被分配到的几率越大
            server 10.0.0.101:80 weight=1;
            server 10.0.0.7:80 weight=2;
    
        #虚拟主机的设置
        server {
            #监听的端口,默认 80
            listen       80;
            #域名,可以有多个
            server_name  localhost;
    
            #默认编码格式
            #charset koi8-r;
    
            #定义本虚拟主机的访问日志
            #access_log  logs/host.access.log  main;
    
            #域名和目录的建立关系
            location / {
                #文件路径
                root   html;
                #默认访问的文件名称,优先级顺序
                index  index.html index.htm;
            }
    	    location /nginx_status{
                #开启状态统计
    	        stub_status on;
                #状态统计不记录日志
    	        access_log ogg;
    	        
    	    }
            #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;
        #    }
        #}
    
    }
    
    
    作者:ccku
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。如有问题或建议,请多多赐教,非常感谢。
  • 相关阅读:
    POJ 1936 All in All
    POJ 2305 Basic remains
    POJ 2081 Recaman's Sequence
    MFC MDI 窗口函数执行顺序
    decompose
    不新建一个文档
    code mistake
    ...
    paper
    stereo
  • 原文地址:https://www.cnblogs.com/ccku/p/13541605.html
Copyright © 2011-2022 走看看