#用户 用户组 user nobody nobody; #错误日志 error_log logs/error.log; #pid文件位置 pid logs/nginx.pid; #nginx 进程数,建议按照cpu 数目来指定,一般为它的倍数 (2个四核的cpu计为8) worker_processes 8; #为每个进程分配cpu,上例中将8 个进程分配到8 个cpu,当然可以写多个,或者将一个进程分配到多个cpu worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; #这个指令是指当一个nginx 进程打开的最多文件描述符数目,理论值应该是最多打开文件数(ulimit -n)与nginx 进程数相除(具体参见http://chongzai.iteye.com/admin/blogs/1900194) worker_rlimit_nofile 65535; events { #事件模型 use epoll; #每个进程允许的最多连接数, 理论上每台nginx 服务器的最大连接数为worker_processes*worker_connections worker_connections 65535; } http { include mime.types; #反向代理配置,可以打开proxy.conf看看 include /etc/nginx/proxy.conf; #fastcgi配置,可以打开fastcgi.conf看看 include /etc/nginx/fastcgi.conf; #日志的格式 log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #访问日志 access_log logs/access.log main; default_type application/octet-stream; fastcgi_intercept_errors on; sendfile on; #服务器名字的hash表 server_names_hash_max_size 32; server_names_hash_bucket_size 32; #客户端请求头部的缓冲区大小,这个可以根据你的系统分页大小来设置, #一般一个请求头的大小不会超过1k,不过由于一般系统分页都要大于1k, #所以这里设置为分页大小。分页大小可以用命令getconf PAGESIZE 取得。 client_header_buffer_size 4k; #这个将为打开文件指定缓存,默认是没有启用的,max 指定缓存数量,建议和打开文件数一致,inactive 是指经过多长时间文件没被请求后删除缓存 open_file_cache max=65535 inactive=36000s; #这个是指多长时间检查一次缓存的有效信息 open_file_cache_valid 3600s; #open_file_cache 指令中的inactive 参数时间内文件的最少使用次数,如果超过这个数字,文件描述符一直是在缓存中打开的,如上例,如果有一个文件在inactive 时间内一次没被使用,它将被移除 open_file_cache_min_uses 1; #keepalive 超时时间 keepalive_timeout 65; #开启或关闭gzip模块(on/off) gzip on; #设置允许压缩的页面最小字节数,页面字节数从header头得content-length中进行获取。默认值是0,不管页面多大都压缩。建议设置成大于1k的字节数,小于1k可能会越压越大 gzip_min_length 1k; #设置系统获取几个单位的缓存用于存储gzip的压缩结果数据流。4 16k代表以16k为单位,安装原始数据大小以16k为单位的4倍申请内存 gzip_buffers 16 64k; #识别http的协议版本 gzip_http_version 1.1; #gzip压缩比,1压缩比最小处理速度最快,9压缩比最大但处理速度最慢(传输快但比较消耗cpu) gzip_comp_level 6; #匹配mime类型进行压缩,无论是否指定,”text/html”类型总是会被压缩的 gzip_types text/plain application/x-javascript text/css application/xml; #和http头有关系,加个vary头,给代理服务器用的,有的浏览器支持压缩,有的不支持,所以避免浪费不支持的也压缩,所以根据客户端的HTTP头来判断,是否需要压缩 gzip_vary on; #是针对每个IP定义一个存储session状态的容器。这个示例中定义了一个10m的容器,按照32bytes/session,可以处理320000个session limit_zone one $binary_remote_addr 10m; #限制每个IP只能发起10个并发连接。 limit_conn one 10; #对每个连接限速300k. 注意,这里是对连接限速,而不是对IP限速。如果一个IP允许10个并发连接,那么这个IP就是限速limit_rate×10 limit_rate 300k; #负载均衡 可以添加权重和负载均衡算法配置 upstream oceanus { server 192.168.168.23:21530; server 192.168.168.24:21530; } upstream wm { server 192.168.168.213:21530; server 192.168.168.224:21530; } server { listen 80; #server_name www.*; if ( $uri = '/' ){ rewrite .* /index.html break; } location ~ ^/good(D|Z|X)/([0-9]+)$ { rewrite ^/good(D|Z|X)/([0-9]+)$ /productsList.html?category$1=$2; } location ~ ^/article/([0-9]+)$ { rewrite ^/article/([0-9]+)$ /articleList.html?categoryID=$1; } location / { #限制上传文件大小 client_max_body_size 10m; proxy_redirect off; #向后台传递真实ip proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://oceanus; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name oceanus.lwl.com; if ( $uri = '/' ){ rewrite .* /index.html break; } #域名主页跳转 location ~ "^/([a-zA-Z]{4,50}$)" { rewrite "^/([a-zA-Z]{4,30}$)" /index.html?domain=$1; } #域名预置页跳转 location ~ /([a-zA-Z]+)/([a-zA-Z]+).html { rewrite /([a-zA-Z]+)/([a-zA-Z]+).html /$2.html?domain=$1&$request_uri; } #域名ajax跳转 location ~ "^/([a-zA-Z]{4,50})/([a-zA-Z]{4,50})/([a-zA-Z]{4,50}$)" { rewrite "^/([a-zA-Z]{4,50})/([a-zA-Z]{4,50})/([a-zA-Z]{4,50}$)" /$2/$3?domain=$1&$request_uri; } #ksh location ~ ^/([a-zA-Z]+)/visualization/([a-zA-Z]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+).html { rewrite ^/([a-zA-Z]+)/visualization/([a-zA-Z]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+).html /visualization/$2/$3/$4.html?domain=$1&$request_uri; } location ~ ^/([a-zA-Z]+)/good(D|Z|X)/([0-9]+)$ { rewrite ^/([a-zA-Z]+)/good(D|Z|X)/([0-9]+)$ /productsList.html?domain=$1&category$2=$3; } location ~ ^/([a-zA-Z]+)/article/([0-9]+)$ { rewrite ^/([a-zA-Z]+)/article/([0-9]+)$ /articleList.html?domain=$1&categoryID=$2; } location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://oceanus; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name i.lwl.com; if ( $uri = '/' ){ rewrite .* /index.html break; } location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://wm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name static.lwl.com; #location ~ "^/goods/pre/([a-zA-Z0-9_]{4,128})\.(jpg|gif|png)" { # rewrite "^/goods/pre/([a-zA-Z0-9_]{4,128})\.(jpg|gif|png)" /goods/pre/$1_$arg_m.$2?version=$arg_version; #} location ~ "^/goods/([0-9]{1,4})/([a-zA-Z0-9]+)/([0-9]{8})/([a-zA-Z0-9]+)\.(jpg|gif|png)" { rewrite "^/goods/([0-9]{1,4})/([a-zA-Z0-9]+)/([0-9]{8})/([a-zA-Z0-9]+)\.(jpg|gif|png)" /goods/$1/$2/$3/$4_$arg_m.$5?version=$arg_version; } #禁止访问doc目录 location ~ ^/(doc)/ { allow 192.168.1.0/24; deny all; } location / { #防盗链 valid_referers none blocked oceanus.lwl.com; if ($invalid_referer) { return 404; } root /alidata/oceanus/static/html; #让浏览器缓存 expires 24h; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name image.lwl.com; location / { expires 24h; root /alidata/oceanus/static/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
相关推荐
nginx.conf nginx常用配置
Nginx常用配置、负载均衡及优化
Nginx常用配置、负载均衡及优化
web建站常用nginx配置参数详解,可以做到基本的通用配置。(虚拟主机,反向代理,域名跳转)
nginx的一些常用配置文件
nginx常用bat批处理命令,放在nginx同级目录下使用,可快速的重启、停止、关闭nginx。 quit.bat(退出Nginx) reload.bat(重启Nginx) stop.bat(停止Nginx)
Nginx常用配置 Nginx配置。 不是最强大,最有生产力或最好的。 只是有用的配置,我想在开箱即用的默认Nginx包中看到 :grinning_squinting_face: 奖励:nginx的fail2ban,filebeat和docker-compose配置:) 警告:我住...
Nginx的常用配置文件,适合负载均衡设置等
nginx最新版本1.19.1以及常用的一些配置文档,本文档自己总结,nginx从官网先下载的。大家若有疑问,可以看我的博客。
Nginx配置学习资料: Nginx常用功能 Nginx配置文件结构 Nginx代理服务的配置说明 Nginx负载均衡详解
nginx正向配置和反向配置 适用于中高级同学 企业内部映射、隧道常用
4、高性能Web服务器Nginx的配置与部署研究(4)Nginx常用命令 内容:Nginx部署中常用的命令,包括启动、测试、停止、发送信号等。 5、高性能Web服务器Nginx的配置与部署研究(5)Nginx配置符号 内容:这篇简短的...
nginx代理功能十分强大,经常用来做反向代理,但有的实际工作环境需要正向代理,经安装发现网上常用的方法有两点问题,1.并不支持https代理,2需要访问的网址一但加上非80端口就会403报错。 后经反复测试,已找到...
Nginx常用的配置命令
3、nginx本身功能复杂,本项目并不能涵盖nginx所有功能,只能配置常用功能,更高级的功能配置仍然需要在最终生成的nginx.conf中进行手动编写。 4、部署此项目后,配置nginx再也不用上网各种搜索,再也不用手动申请和...
一、简明nginx常用命令 1. 启动 Nginx 代码如下:poechant@ubuntu:sudo ./sbin/nginx2. 停止 Nginx 代码如下:poechant@ubuntu:sudo ./sbin/nginx -s stoppoechant@ubuntu:sudo ./sbin/nginx -s quit-s都是采用向 ...
3 Nginx常用命令管理及升级.rar 4 Nginx配置文件精讲一.rar 5 Nginx配置文件精讲二及多站点配置。rar 6企业实战Nginx+Tomcati动静分离架构.rar 7企业实战Nginx+PHP(FastCGI)高性能服务器.rar 8 Nginx与Tomcat-PHP...
b)常用的 Nginx 参数 - 3 - c)静态文件处理 - 4 - d)动态页面请求处理 - 4 - e)下面为nginx.conf配置实例: - 5 - f)Nginx 启动,停止等命令 - 8 - (2) Resin安装配置 - 9 - 1) Resin安装 - 9 - 2) Resin配置 - 9 - ...
windows下配置nginx反向代理tomcat,从下载地址开始讲起,第二步讲常用命令 第三步讲了一个实例,第四步是配置说明
06.nginx常用的命令 07.nginx的配置文件 08.nginx配置实例(反向代理准备工作) 09.nginx配置实例(反向代理实例一) 10.nginx配置实例(反向代理实例二) 11.nginx配置实例(负载均衡) 12.nginx配置实例...