Tengine/2.1.2 (nginx/1.6.2) 测试配置

简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
前端tenginx 配置
 
cat  / usr / local / tengine / conf / nginx.conf
user nginx nginx;
                                                                                                                                                                                                                                           
worker_processes auto;
worker_cpu_affinity auto;
                                                                                                                                                                                                                                           
error_log  / var / log / tengine / error.log crit;
pid  / var / run / nginx.pid;
google_perftools_profiles  / var / tmp / tcmalloc;
                                                                                                                                                                                                                                           
worker_rlimit_nofile  65535 ;
                                                                                                                                                                                                                                           
dso {
     load ngx_http_rewrite_module.so;
     load ngx_http_access_module.so;
     load ngx_http_concat_module.so;
     load ngx_http_limit_conn_module.so;
     load ngx_http_limit_req_module.so;
     load ngx_http_upstream_session_sticky_module.so;
     load ngx_http_cache_purge_module.so;
     load ngx_http_trim_filter_module.so;
}
                                                                                                                                                                                                                                           
events {
     use epoll;
     worker_connections  10240 ;
}
                                                                                                                                                                                                                                           
http {
  
     proxy_ignore_client_abort on;
     add_header Access - Control - Allow - Origin  * ;
     server_tokens off;
     server_tag off;
     autoindex off;
     access_log off;
     include mime.types;
     default_type application / octet - stream;
                                                                                                                                                                                                                                              
     server_names_hash_bucket_size  128 ;
     client_header_buffer_size  32k ;
     large_client_header_buffers  4  32k ;
     client_max_body_size  10m ;
     client_body_buffer_size  256k ;
                                                                                                                                                                                                                                              
     sendfile on;
     tcp_nopush on;
     keepalive_timeout  60 ;
     tcp_nodelay on;
                                                                                                                                                                                                                                              
     gzip on;
     gzip_min_length  1k ;
     gzip_buffers  4  16k ;
     gzip_http_version  1.0 ;
     gzip_comp_level  2 ;
     gzip_types text / plain application / x - javascript text / css application / xml;
     gzip_vary on;
                                                                                                                                                                                                                                              
     proxy_connect_timeout  600 ;
     proxy_read_timeout  600 ;
     proxy_send_timeout  600 ;
     proxy_buffer_size  128k ;
     proxy_buffers  4  128k ;
     proxy_busy_buffers_size  256k ;
     proxy_temp_file_write_size  256k ;
     proxy_headers_hash_max_size  1024 ;
     proxy_headers_hash_bucket_size  128 ;
                                                                                                                                                                                                                                              
     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_temp_path  / data / nginx_temp / nginx_temp;
     proxy_cache_path  / data / nginx_temp / nginx_cache levels = 1 : 2  keys_zone = cache_one: 2048m  inactive = 30m  max_size = 60g ;
                                                                                                                                                                                                                                              
     include  SET / * .conf;
                                                                                                                                                                                                                                              
     
     log_format access  '$HTTP_X_REAL_IP - $remote_user [$time_local] "$request"'
          '$status $body_bytes_sent "$http_referer" '
          '"$http_user_agent" $HTTP_X_Forwarded_For' ;
                                                                                                                                                                                                                                         
     server {
         sysguard on;
                                                                                                                                                                                                                                                  
         sysguard_load load = 10.5  action = / loadlimit;
         sysguard_mem swapratio = 20 %  action = / swaplimit;
         sysguard_mem free = 100M  action = / freelimit;
                                                                                                                                                                                                                                                  
         location  / loadlimit {
             return  503 ;
         }
                                                                                                                                                                                                                                                  
         location  / swaplimit {
             return  503 ;
         }
                                                                                                                                                                                                                                                  
         location  / freelimit {
             return  503 ;
         }
     }
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              
     include   / usr / local / tengine / conf / conf.d / * .conf;
}
 
 
cat cdn.conf
server {
         listen   80 ;
         server_name     cdn.com;
         error_log       cdn.error;
 
if  ($time_iso8601 ~  "^(d{4})-(d{2})-(d{2})T(d{2}):(d{2}):(d{2})" )
{
set  $year1 $ 1 ;
set  $month1 $ 2 ;
set  $day1 $ 3 ;
set  $hour1 $ 4 ;
set  $minutes1 $ 5 ;
set  $seconds1 $ 6 ;
}
access_log   / opt / log / cdn - $year - $month - $day.log;
 
location  / webscan_360_cn.html
{
root  / usr / local / tengine / html / cdn;
}
 
location  /  {
       proxy_pass http: / / ip2: 8180 / ;   
}
}
 
cat h5.conf
server {
     listen  80 ;
     server_name h5.com;
     index index.html index.htm index.php;
     access_log on;
                                                                                                                                                                               
     trim on;
     location  / webscan_360_cn.html
{
root  / usr / local / tengine / html / h5;
}
 
                                                                                                                                                                               
     location  /  {
         proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
         proxy_pass http: / / h5;
         
    if  ($http_range ~  "\d{9,}" ) {
     return  444 ;
      }
    if  ( $host !~ *  'h5.com'  ) {
     return  403 ;
    }
    }                                                                                                  location ~ . * \.(php)?$ {
         proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
         proxy_pass http: / / h5;
     }
                                                                                                                                                                                                                                                                                                                                                             
     location ~  / purge( / . * ) {
         allow  127.0 . 0.1 ;
         allow  198.x .x. 0 / 24 ;
         deny  all ;
     }
                                                                                                                                                                               
     location ~ . * \.(htm|js|css|gif|jpg|jpeg|png|bmp|ico|swf|flv)$ {
         proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
         proxy_cache cache_one;
         proxy_cache_valid  200  304  15m ;
         proxy_cache_valid  301  302  10m ;
         proxy_cache_valid  any  1m ;
         proxy_cache_key $host$uri$is_args$args;
         add_header Ten - webcache  '$upstream_cache_status from $host' ;
         proxy_pass http: / / h5;
         expires  30m ;
     }
                   
     #上满这段无效                                                                                                                                                            
     location ~  / \.ht {
         deny  all ;
     }
                                                                                                                                                                               
     access_log  / data / logs / web / h5 / access.log access;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
后端的nginx 配置(ip2)
cat cdn.conf
server {
         listen   8180 ;
         server_name     cdn.com;
         access_log      cdn.log;
         error_log       cdn.error;
         root xx;
         location  /  {
          index index.php index.html index.htm;
     }
     location ~ ^ / (images|javascript|js|css|flash|media|static|html) /  {
expires  10s ;
}
 
location ~ .php$ {
             fastcgi_pass  127.0 . 0.1 : 9000 ;
             fastcgi_index index.php;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             include fastcgi_params;
         }
 
location ~  / .ht {
             deny  all ;
         }
 
}


查看后端服务器状态

location /nstatus {

check_status;

#access_log off;

#allow SOME.IP.ADD.RESS;

#deny all;

}     

wKiom1lVu_6DIfJpAAAvZJVdj58169.png-wh_50

wKiom1lVvAfzYtoEAAA8JYqf0rY470.png-wh_50



本文转自 liqius 51CTO博客,原文链接:http://blog.51cto.com/szgb17/1943401,如需转载请自行联系原作者

相关实践学习
Serverless极速搭建Hexo博客
本场景介绍如何使用阿里云函数计算服务命令行工具快速搭建一个Hexo博客。
相关文章
|
10天前
|
应用服务中间件 BI nginx
Nginx的location配置详解
【10月更文挑战第16天】Nginx的location配置详解
|
18天前
|
缓存 负载均衡 安全
Nginx常用基本配置总结:从入门到实战的全方位指南
Nginx常用基本配置总结:从入门到实战的全方位指南
191 0
|
3天前
|
应用服务中间件 API nginx
nginx配置反向代理404问题
【10月更文挑战第18天】本文介绍了使用Nginx进行反向代理的配置方法,解决了404错误、跨域问题和302重定向问题。关键配置包括代理路径、请求头设置、跨域头添加以及端口转发设置。通过调整`proxy_set_header`和添加必要的HTTP头,实现了稳定的服务代理和跨域访问。
nginx配置反向代理404问题
|
3天前
|
Web App开发 定位技术 iOS开发
Playwright 是一个强大的工具,用于在各种浏览器上测试应用,并模拟真实设备如手机和平板。通过配置 `playwright.devices`,可以轻松模拟不同设备的用户代理、屏幕尺寸、视口等特性。此外,Playwright 还支持模拟地理位置、区域设置、时区、权限(如通知)和配色方案,使测试更加全面和真实。例如,可以在配置文件中设置全局的区域设置和时区,然后在特定测试中进行覆盖。同时,还可以动态更改地理位置和媒体类型,以适应不同的测试需求。
Playwright 是一个强大的工具,用于在各种浏览器上测试应用,并模拟真实设备如手机和平板。通过配置 `playwright.devices`,可以轻松模拟不同设备的用户代理、屏幕尺寸、视口等特性。此外,Playwright 还支持模拟地理位置、区域设置、时区、权限(如通知)和配色方案,使测试更加全面和真实。例如,可以在配置文件中设置全局的区域设置和时区,然后在特定测试中进行覆盖。同时,还可以动态更改地理位置和媒体类型,以适应不同的测试需求。
9 1
|
7天前
|
缓存 负载均衡 应用服务中间件
Nginx配置
【10月更文挑战第22天】在实际配置 Nginx 时,需要根据具体的需求和环境进行调整和优化。同时,还需要注意配置文件的语法正确性和安全性。
26 7
|
16天前
|
前端开发 JavaScript 应用服务中间件
终极 Nginx 配置指南
本文介绍了Nginx的基本配置及其优化方法。首先,通过删除注释简化了Nginx的默认配置文件,使其更易于理解。接着,文章将Nginx配置文件分为全局块、events块和http块三部分进行详细解释。此外,还提供了如何快速上线网站、解决前端history模式404问题、配置反向代理、开启gzip压缩、设置维护页面、在同一IP上部署多个网站以及实现动静分离的具体配置示例。最后,附上了Nginx的基础命令,包括安装、启动、重启和关闭等操作。
|
20天前
|
负载均衡 应用服务中间件 nginx
Nginx的6大负载均衡策略及权重轮询手写配置
【10月更文挑战第9天】 Nginx是一款高性能的HTTP服务器和反向代理服务器,它在处理大量并发请求时表现出色。Nginx的负载均衡功能可以将请求分发到多个服务器,提高网站的吞吐量和可靠性。以下是Nginx支持的6大负载均衡策略:
102 7
|
18天前
|
缓存 前端开发 JavaScript
一、nginx配置
一、nginx配置
111 1
|
17天前
|
JavaScript 前端开发 应用服务中间件
vue前端开发中,通过vue.config.js配置和nginx配置,实现多个入口文件的实现方法
vue前端开发中,通过vue.config.js配置和nginx配置,实现多个入口文件的实现方法
90 0
|
20天前
|
缓存 监控 负载均衡
nginx相关配置及高并发优化
Nginx的高并发优化是一个综合性的过程,需要根据具体的业务场景和硬件资源量身定制。以上配置只是基础,实际应用中还需根据服务器监控数据进行持续调整和优化。例如,利用工具如ab(Apache Benchmarks)进行压力测试,监控CPU、内存、网络和磁盘I/O等资源使用情况,确保配置的有效性和服务的稳定性。
78 0