[转帖]高并发下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 [字体:大 中 小] 注:下文涉及到配置的,如无特别 ...
随机推荐
- Python——第五章:pickle模块
序列化:把对象转化成二进制字节 反序列化:把二进制字节转化回对象 Pickle模块的常见用法: Pickle.dunps 把对象(数据)转化成字节 Pickle.loads 把字节转化回对象( ...
- Pytest07-pytest.ini配置文件
1.pytest配置文件 固定名称:pytest.ini 作用域:当前目录及子目录 具体配置功能见下: [pytest] # 01 把命令行参数自动添加到这里 addopts = -s -v --ht ...
- Liquid 常用语法记录
一.什么是 Liquid Liquid 是一款专为特定需求而打造的模板引擎. Liquid 中有两种类型的标记:Output 和 Tag. Output 通常用来显示文本 {{ 两个花括号 }} Ta ...
- 如何开发一个ORM数据库框架
如何开发一个ORM框架 ORM(Object Relational Mapping)对象关系映射,ORM的数据库框架有hibernate,mybatis.我该如何开发一个类似这样的框架呢? 为什么会有 ...
- wangEditor出现初始化编辑器时候未传入任何参数,请查阅文档
wangEditor出现初始化编辑器时候未传入任何参数,请查阅文档 出现的原因可能是你未在初始视图.元素未创建.created.模态框.弹窗.抽屉中使用,你应该在div元素创建了再执行初始渲染, 解决 ...
- 2023-11-04:用go语言,如果n = 1,打印 1*** 如果n = 2,打印 1*** 3*** 2*** 如果n = 3,打印
2023-11-04:用go语言,如果n = 1,打印 1*** 如果n = 2,打印 1*** 3*** 2*** 如果n = 3,打印 1*** 3*** 2*** 4*** 5*** 6*** ...
- Typecho 反向代理 http 访问强制启用生成 https 链接
问题描述 微酷是使用Nginx反向代理内网的Typecho站点,为了效率内网访问不需要使用https,这样Typecho接收到的请求是http协议的,于是网站内部资源链接被修改成了http. 解决方案 ...
- 自定义TBE算子入门,不妨从单算子开发开始
摘要:以单算子开发为例,带你了解算子开发及测试全流程. 为什么要自定义算子 深度学习算法由一个个计算单元组成,我们称这些计算单元为算子(Operator,简称Op).算子是一个函数空间到函数空间上的映 ...
- 云图说丨初识云应用引擎CAE
摘要:开发运营一个应用软件,面临种种挑战:软件栈厚重.开发上线慢.资源易浪费.运维投入高.突发流量应对困难. 华为云应用引擎CAE面对挑战,一扫而光!! 本文分享自华为云社区<[云图说] | 第 ...
- 升级win11显示:此版本的windows不支持该处理器—如何强升win11?
今天的我微信笔记本 msi gp62 mvr 无论是win10升级到win11 还是安装win11都无法安装.显示: Windows 11不支持该处理器 win11系统升级标准要求相比win10来说有 ...