Nginx动静分离及性能调优实践
来源:互联网 发布:java循环拼接字符串 编辑:程序博客网 时间:2024/06/05 23:51
直接看配置文件!直接看配置文件!直接看配置文件!
#user nobody;worker_processes 8;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;#----------------Nginx优化参数---------------Start-----------------###worker_rlimit_nofile 65535;#----------------Nginx优化参数---------------End-------------------###events { worker_connections 1024;use epoll;}http { include mime.types; default_type application/octet-stream; #----------------Nginx优化参数--------------Start------------------###open_file_cache max=2048 inactive=20s;#最多缓存n个文件,缓存多少时间 open_file_cache_valid 30s;#多少时间检查一次,如果发现30s内没有用过2次的删除 open_file_cache_min_uses 2;#在30S中没有使用到这个配置的次数的话就删除 open_file_cache_errors on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 15; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k;#开启GZIPgzip on; gzip_disable "MSIE [1-6]\."; gzip_proxied any;gzip_http_version 1.1; gzip_comp_level 4; gzip_buffers 16 8k; gzip_min_length 1k; gzip_vary on; gzip_types text/plain text/css image/gif image/jpeg image/png application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; #----------------Nginx优化参数---------------End-------------------### log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' '$upstream_addr $upstream_response_time $request_time ' '$http_true_client_ip '; #---优化项目----------------关闭Nginx访问日志 # access_log logs/access.log main; server_tokens off; #关闭版本显示 sendfile on; #防止ddos攻击 client_header_timeout 10; client_body_timeout 10; #h5-no sessionupstream balanceNoSessionServer{ #---优化项目----------------转换为本机物理IP server 10.3.1.18:8003 ; server 10.3.1.18:8004 ; server 10.3.1.18:8005 ; server 10.3.1.18:8006 ;}#h5-star service upstream balanceSessionServer{ sticky httponly; #---优化项目----------------转换为本机物理IP server 10.3.1.18:8003 ; server 10.3.1.18:8004 ; server 10.3.1.18:8005 ; server 10.3.1.18:8006 ;} server { listen 8088; server_name localhost; #charset koi8-r;#--------------------------动静分离-----------------静态资源映射-------------------# location ~ /(proh5|proh5-itr-services)/.*\.(gif|jpg|jpeg|png|bmp|ico|css|js|html)$ { #指定静态资源根目录 #静态资源查找逻辑为:/app/nginx/static/proh5/index.html # /app/nginx/static/proh5-itr-services/index.html root /app/nginx/static;}#--------------------------动静分离-----------------动态资源映射-------------------# location ~ /proh5/.*\.(jsp|do|action|jspx)$ { proxy_pass http://balanceNoSessionServer$request_uri; proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP $remote_addr; #支撑后端获取源IPproxy_redirect off;proxy_set_header Host $http_host;proxy_set_header Connection Close;port_in_redirect off;proxy_connect_timeout 60s;proxy_read_timeout 60s;proxy_send_timeout 60s;proxy_buffer_size 4k;proxy_buffers 6 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;proxy_intercept_errors off;#---------------------------------Nginx优化参数--------------Start------------------### client_body_buffer_size 128k; }location ~ /proh5-itr-services/.*\.(jsp|do|action|jspx)$ { proxy_pass http://balanceSessionServer$request_uri; proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP $remote_addr; #支撑后端获取源IPproxy_redirect off;proxy_set_header Host $http_host;proxy_set_header Connection Close;port_in_redirect off;proxy_connect_timeout 60s;proxy_read_timeout 60s;proxy_send_timeout 60s;proxy_buffer_size 4k;proxy_buffers 6 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;proxy_intercept_errors off;#---------------------------------Nginx优化参数--------------Start------------------### client_body_buffer_size 128k; } location ~ ^/WEB-INF/ { deny all; } location /res { alias /app2/resource/images; index index.html index.htm;expires 1d; } #设置健康检查页面location = /healthcheck.html { root /app/nginx/html;access_log off; #关闭健康检查访问日志 }#设置404页面[/app/nginx/html目录下的文件]error_page 404 403 /404.html;location = /404.html { root /app/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /app/nginx/html; } }}
0 0
- Nginx动静分离及性能调优实践
- Nginx+Tomcat动静分离及Nginx优化
- Nginx+Tomcat动静分离及Nginx优化
- nginx 反向代理及动静分离
- nginx入门配置,及动静分离
- nginx +lnmp 负载均衡及动静分离
- nginx配置反向代理及动静分离
- 【架构】 Nginx动静分离
- Nginx + Tomcat 动静分离
- nginx设置动静分离
- Nginx实现动静分离
- Nginx动静分离实现
- nginx+tomcat动静分离
- nginx动静分离演示
- Nginx动静分离
- nginx动静分离
- nginx +tomcat 动静分离
- Nginx动静分离实现
- cstring与string头文件与输出
- apt-cache命令的常规用法
- Andriod内存
- 我从1万小时编程中学到了什么
- Node的特点
- Nginx动静分离及性能调优实践
- C++中const 的用法
- (接上)第7题1到49两个不相邻加号改乘号
- javax.servlet.jsp.tagext 在哪个jar包
- Node简介
- 泛型一
- String,StringBuffer与StringBuilder之间区别
- 实用程序集锦
- perl 子程序的使用