nginx 配置参数详解
admin
2023-03-21 19:01:13
0

[root@WEBServer10414 ~]# cat /etc/nginx/nginx.conf

#user  nobody;#定义nginx运行的用户和用户组
user root;
worker_processes  8;#nginx进程数,建议设置为等于CPU总核心数

#error_log  logs/error.log;#错误日志路径
#error_log  logs/error.log  notice;#错误日志类型,如[debug | info | notice | warn | error | crit ]
#error_log  logs/error.log  info;错误日志类型

#pid        logs/nginx.pid;#进程文件

worker_rlimit_nofile 51200;#一个nginx进程打开的最多文件描述符数目,理论值应该是最多打开文件数(系统的值ulimit)


events {#工作模式与连接数上限
    use epoll;#参考事件模型[ kqueue | rtsig | epoll | /dev/poll | select | poll ];
    worker_connections  51200;#单个进程最大连接数
}


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        on;#开启高效文件传输模式
    #tcp_nopush     on;#防止网络阻塞

    #keepalive_timeout  0;
    keepalive_timeout  120;#长连接超时时间,单位是秒

    
    upstream backend {#upstream的负载均衡,
        ip_hash;#使用ip_hash的算法
        server 50.50.50.16:8020;#realserver的IP和端口号
        server 50.50.50.13:8020;#realserver的IP和端口号
    }

    
    #gzip  on;#开启gzip压缩输出

    server {          #虚拟主机的配置
        listen       8080;             #虚拟主机监听的端口号
        server_name  WEBServer10414;            #虚拟主机的域名或主机名
        if ( $host ~* "\d+\.\d+\.\d+\.\d+" ) {
                                        return 400;
                                }


        charset utf-8;默认编码

        #access_log  logs/host.access.log  main;#定义本虚拟主机的访问日志

        location / {#对“/”启用反向代理
           # root   html;
           index  index.jsp  index.html index.htm; #可以识别的索引文件的类型
           proxy_set_header Host $host:8080;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Real-Port $remote_port;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
           proxy_pass http://backend;

           proxy_buffer_size          64k;#设置代理服务器(nginx)保存用户头信息的缓冲区大小
           proxy_buffers              64 128k;#proxy_buffers缓冲区
           proxy_busy_buffers_size    256k;#高负荷下缓冲大小(proxy_buffers * 2)
           proxy_temp_file_write_size 256k;#设定缓存文件夹大小,将从upstream服务器传
           }

         location /nstatus {#设定查看nginx状态的地址
                check_status;
                access_log off;
        }

           

        #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;
        #}
    }

         upstream backend1 {
        ip_hash;
        server 50.50.50.16:8030;
        server 50.50.50.13:8030;
    }
       server {
        listen       8090;
        server_name  WEBServer10414;


      charset utf-8;
        location /stsadmin-cm/ {
            index index.jsp index.htm index.html;
            proxy_pass http://backend1/stsadmin-cm/;
            proxy_redirect default;
            proxy_buffer_size          16k;
            proxy_buffers              16 128k;
            proxy_busy_buffers_size    256k;
            proxy_temp_file_write_size 256k;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

}
    # 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;
    #    }
    #}

}

相关内容

热门资讯

伊朗东南部城市恰巴哈尔传出爆炸... 总台记者获悉,当地时间10日13时左右,伊朗东南部沿海城市恰巴哈尔传出爆炸声。恰巴哈尔政府部门随后通...
微晶石瓷砖为什么都不卖了 最佳回答 有一段时间微晶石瓷砖确实非常流行,不过由于这种微晶石瓷砖具有很多缺点,所以导致现在的瓷砖...
燃气灶后面贴瓷砖怎么处理 燃气灶后面贴瓷砖是一个很好的选择,能够美观地装饰并保护墙壁。但是,贴瓷砖需要注意一些细节,以确保安装...
墙面瓷砖掉落补瓷砖 1、观察砂浆方面的情况,如果砂浆没有松动的话,将瓷砖背面四周粘结的砂浆进行刮净,将瓷砖用胶水粘结便可...
防水做满墙是不是瓷砖贴不稳 不会贴不牢,只是施工的时候会麻烦些。因为瓷砖背面抹上水泥砂浆,水分本来会渗入墙面变干凝固,但是有了防...
不敲瓷砖做防水靠谱吗 最佳回答 相比较下来不敲瓷砖做防水还是不太靠谱的,现在基本上家里面做防水都是需要在贴瓷砖之前做好的,...
广西来宾市委原书记何朝建被“双... 经自治区党委批准,自治区纪委监委对来宾市委原书记何朝建严重违纪违法问题进行了立案审查调查。经查,何朝...
武大:极不认同OPPO母亲节广... 学校极不认同某手机厂商“母亲节”广告文案的内容表述和价值倾向。这与武汉大学立德树人的育人理念严重不符...
不法人员“刘佳”冒充下属企业投... 澎湃新闻记者 岳怀让5月7日,中国国新控股有限责任公司(简称“中国国新”)在官网发布了一则《关于不法...
“拖延军购只会使中国大陆获利”... 台立法机构5月8日表决通过蓝白版“军购特别条例”,预算上限由赖清德当局要求的1.25万亿新台币降至7...