[转帖]高并发下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 [字体:大 中 小] 注:下文涉及到配置的,如无特别 ...
随机推荐
- Windows和Linux下通过go实现自删除
自删除在攻防中都挺常见的,自写远控通常也有需要.可是在度娘里搜不到什么办法,于是就查查Windows api学习记录一回. linux 先获得当前程序的文件名,再使用syscall这个包中的Unlin ...
- k8s环境设置-pod下载及重启策略
k8s环境设置 在我们开始使用k8s之前,我们可以先做一些环境配置,使k8s更加的方便使用 第一个要做的就是kubectl命令的补全 在使用kubectl的时候你会发现参数你是Tab不出来的,这时候我 ...
- 扩展中国剩余定理(Excrt)笔记
扩展中国剩余定理(excrt) 本来应该先学中国剩余定理的.但是有了扩展中国剩余定理,朴素的 CRT 就没用了. 扩展中国剩余定理用来求解如下形式的同余方程组: \[\begin{cases} x \ ...
- IPv6规模部署和应用成必然趋势,IPv6监测具有很大市场潜力
日前,中央网信办.国家发展改革委.工业和信息化部联合印发<深入推进IPv6规模部署和应用2021年工作安排>.这更深入的表明,IPv6规模部署和应用是互联网演进升级的必然趋势,是网络技术创 ...
- Java中常用不可变类
Java中常用的不可变类是指一旦被创建,它们的值就不可更改的类.在实际开发中,使用不可变类时可以带来多种优点,比如线程安全.缓存.副本等.下面我们将介绍Java中常见的不可变类: 1.字符串(Stri ...
- API安全技术
自己在日常工作中会涉及到些安全的概念,但是没有成体系,因此最近研读了<API安全技术与实战>一书,在此做些文章记录. API安全是从安全的角度关注API领域的安全问题和这些问题的解决方案, ...
- 神经网络基础篇:向量化(Vectorization)
向量化 向量化是非常基础的去除代码中for循环的艺术,在深度学习安全领域.深度学习实践中,会经常发现自己训练大数据集,因为深度学习算法处理大数据集效果很棒,所以的代码运行速度非常重要,否则如果在大数据 ...
- 大数据实践解析(下):Spark的读写流程分析
导读: 众所周知,在大数据/数据库领域,数据的存储格式直接影响着系统的读写性能.spark是一种基于内存的快速.通用.可扩展的大数据计算引擎,适用于新时代的数据处理场景.在"大数据实践解析( ...
- 火山引擎AB测试:广告实验深度打通巨量引擎,高效测试广告素材
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 近期,火山引擎AB测试DataTester上线了新版的广告AB实验,还推出了与巨量引擎深度打通的能力.用户可以 ...
- 火山引擎 DataTester 为企业降本增效:1 个人也能成为一支 A/B 实验团队
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 今年天猫电商.京东均表示交易规模与 2021 年持平,跟往年急剧增长的销售额相比,今年的双十一显得略微" ...