[转帖]高并发下nginx配置模板
| user web; | |
| # One worker process per CPU core. | |
| worker_processes 8; | |
| # Also set | |
| # /etc/security/limits.conf | |
| # web soft nofile 65535 | |
| # web hard nofile 65535 | |
| # /etc/default/nginx | |
| # ULIMIT="-n 65535" | |
| worker_rlimit_nofile 65535; | |
| pid /run/nginx.pid; | |
| events { | |
| # | |
| # Determines how many clients will be served by each worker process. | |
| # (Max clients = worker_connections * worker_processes) | |
| # Should be equal to `ulimit -n / worker_processes` | |
| # | |
| worker_connections 65535; | |
| # | |
| # Let each process accept multiple connections. | |
| # Accept as many connections as possible, after nginx gets notification | |
| # about a new connection. | |
| # May flood worker_connections, if that option is set too low. | |
| # | |
| multi_accept on; | |
| # | |
| # Preferred connection method for newer linux versions. | |
| # Essential for linux, optmized to serve many clients with each thread. | |
| # | |
| use epoll; | |
| } | |
| http { | |
| ## | |
| # Basic Settings | |
| ## | |
| # | |
| # Override some buffer limitations, will prevent DDOS too. | |
| # | |
| client_body_buffer_size 10K; | |
| client_header_buffer_size 1k; | |
| client_max_body_size 8m; | |
| large_client_header_buffers 2 1k; | |
| # | |
| # Timeouts | |
| # The client_body_timeout and client_header_timeout directives are | |
| # responsible for the time a server will wait for a client body or | |
| # client header to be sent after request. If neither a body or header | |
| # is sent, the server will issue a 408 error or Request time out. | |
| # | |
| # The keepalive_timeout assigns the timeout for keep-alive connections | |
| # with the client. Simply put, Nginx will close connections with the | |
| # client after this period of time. | |
| # | |
| # Finally, the send_timeout is a timeout for transmitting a response | |
| # to the client. If the client does not receive anything within this | |
| # time, then the connection will be closed. | |
| # | |
| # | |
| # send the client a "request timed out" if the body is not loaded | |
| # by this time. Default 60. | |
| # | |
| client_body_timeout 32; | |
| client_header_timeout 32; | |
| # | |
| # Every 60 seconds server broadcasts Sync packets, so 90 is | |
| # a conservative upper bound. | |
| # | |
| keepalive_timeout 90; # default 65 | |
| send_timeout 120; # default 60 | |
| # | |
| # Allow the server to close the connection after a client stops | |
| # responding. | |
| # Frees up socket-associated memory. | |
| # | |
| reset_timedout_connection on; | |
| # | |
| # Open file descriptors. | |
| # Caches information about open FDs, freqently accessed files. | |
| # | |
| open_file_cache max=200000 inactive=20s; | |
| open_file_cache_valid 30s; | |
| open_file_cache_min_uses 2; | |
| open_file_cache_errors on; | |
| # | |
| # Sendfile copies data between one FD and other from within the kernel. | |
| # More efficient than read() + write(), since the requires transferring | |
| # data to and from the user space. | |
| # | |
| sendfile on; | |
| # Tcp_nopush causes nginx to attempt to send its HTTP response head in one | |
| # packet, instead of using partial frames. This is useful for prepending | |
| # headers before calling sendfile, or for throughput optimization. | |
| tcp_nopush on; | |
| # | |
| # don't buffer data-sends (disable Nagle algorithm). Good for sending | |
| # frequent small bursts of data in real time. | |
| # | |
| tcp_nodelay on; | |
| types_hash_max_size 2048; | |
| include /etc/nginx/mime.types; | |
| default_type application/octet-stream; | |
| ## | |
| # Logging Settings | |
| ## | |
| # | |
| # Use analytics to track stuff instead of using precious file IO resources. | |
| # Disabling logging speeds up IO. | |
| # | |
| access_log off; | |
| error_log /root/PROJECTS/logs/error.log crit; | |
| ## | |
| # Gzip Settings | |
| ## | |
| gzip on; | |
| gzip_disable "MSIE [1-6]\."; | |
| # Only allow proxy request with these headers to be gzipped. | |
| gzip_proxied expired no-cache no-store private auth; | |
| # Default is 6 (1<n<9), but 2 -- even 1 -- is enough. The higher it is, the | |
| # more CPU cycles will be wasted. | |
| gzip_comp_level 9; | |
| gzip_min_length 500; # Default 20 | |
| gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
| ## | |
| # Virtual Host Configs | |
| ## | |
| include /etc/nginx/conf.d/*.conf; | |
| } |
[转帖]高并发下nginx配置模板的更多相关文章
- nginx配置模板问题404
nginx配置模板问题 一.nginx主配置文件如下 cat /etc/nginx/nginx.conf user nginx; worker_processes ; #error_log logs/ ...
- 阿里云Linux CentOS8.1 64位服务器安装LNMP(Linux+Nginx+MySQL+PHP) 并发调试之Nginx配置
搭建好LNMP环境之后,接着要考虑的就是整个系统的并发能力了. 一.Nginx的配置 Nginx有很好的并发能力.但是要想使它的并发能力能够施展出来,需要在初步安装好的Nginx上做一些配置.主要需要 ...
- GitLab 配置模板
GitLab 配置模板 GitLab 使用模板和参数生成配置文件. 一般来说,我们会通过 gitlab.rb 文件修改配置,例如 Nginx 相关配置. gitlab.rb 只能使用特定的几个 Ngi ...
- 高并发下的 Nginx 优化与负载均衡
高并发下的 Nginx 优化 英文原文:Optimizing Nginx for High Traffic Loads 过去谈过一些关于Nginx的常见问题; 其中有一些是关于如何优化Nginx. ...
- 高并发下的Nginx优化
高并发下的Nginx优化 2014-08-08 13:30 mood Nginx 过去谈过一些关于Nginx的常见问题; 其中有一些是关于如何优化Nginx. 很多Nginx新用户是从Apach ...
- JAVA跨域、RestTemplate高并发下异常与配置、JSON数据Long转String
## 跨域支持 import org.springframework.context.annotation.Bean; import org.springframework.context.annot ...
- Nginx 配置实例-配置高可用
Nginx 配置实例-配置高可用 1. 实现效果 2. 两台机器 nginx 的安装 2.1 192.168.25.120 中 nginx 的安装 2.1.1 安装 pcre 依赖 2.1.2 安装其 ...
- [转帖]nginx配置ssl加密(单/双向认证、部分https)
nginx配置ssl加密(单/双向认证.部分https) https://segmentfault.com/a/1190000002866627 nginx下配置ssl本来是很简单的,无论是去认证 ...
- [转帖]nginx配置ssl证书实现https访问
https://www.cnblogs.com/tianhei/p/7726505.html 今天就是如此处理的 感觉挺不错的. 一,环境说明 服务器系统:ubuntu16.04LTS 服务器IP地址 ...
- CentOS7.1下生产环境Keepalived+Nginx配置
CentOS7.1下生产环境Keepalived+Nginx配置 [日期:2015-07-20] 来源:Linux社区 作者:soulful [字体:大 中 小] 注:下文涉及到配置的,如无特别 ...
随机推荐
- WinRM服务应用及配置说明
一.什么是winRM服务 1.1.winRM服务介绍 Windows远程管理(WinRM)服务是Windows Server 2003 R2以上版本中一种新式的方便远程管理的服务.通过WinRM服务, ...
- uni-app+vue3+ts项目搭建完整流程
项目代码同步更新至码云 uni-vue3-ts-template 开发前准备 利用 uni-app 开发,有两种方法: 通过 HBuilderX 创建(需安装 HBuilderX 编辑器) 通过命令行 ...
- 【wing】一款轻量快捷的团队开发工具
导航 开源地址:[Github] & [Gitee] 新手使用 更多命令 开发指南 说明 wing是一个代码同步管理工具类似repo,具有以下特性: 支持Winddows .Linux .Ma ...
- Mybatis源码4 Cache的实现和其原理
Mybatis CachingExecutor, 二级缓存,缓存的实现 一丶二级缓存概述 上一章节,我们知道mybaits在构造SqlSession的时候,需要让SqlSession持有一个执行器,如 ...
- Cesium渲染一帧中用到的图形技术
译者注:本文翻译自Cesium官方博文<Graphics Tech in Cesium - Rendering a Frame>,May 14, 2015 by Patrick Cozzi ...
- 云小课丨SA基线检查:给云服务来一次全面“体检”
摘要:随着企业上云进程的加快,由于云服务配置不合理.不合规等引发的安全风险与日俱增.如果没有加以重视并做及时的诊断处置,将会对企业云上业务带来巨大的安全隐患. 本文分享自华为云社区<云小课丨安全 ...
- Asp.net MVC 跨域设置
.Net Core 跨域 <system.webServer> <httpProtocol> <customHeaders> <add name=" ...
- PPT 动画-滚动数字
插入一个文本框,输入 0~9 调整边框大小,使其竖着排列 页面切换,选择平滑
- git一个空分支
如果不想要当前创建的分支拥有创建节点之前的内容,就需要一个完全为空的分支,可以参考知乎这篇文章. 使用git checkout -b命令创建的分支是有父节点的,这意味着新的分支包含了历史提交,所以我们 ...
- Sunshine + Moonlight 纯软件实现全平台设备作 Linux 副屏
目录 初识 Moonlight 部署 Sunshine 服务端与 Moonlight 客户端 创建虚拟显示屏 写一个创建屏幕的脚本(可选) 将副屏进行串流 已知问题 最近,我想要通过视频学习一些技术知 ...