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,如需转载请自行联系原作者

相关文章
|
1月前
|
编解码 应用服务中间件 Linux
centos配置nginx-rtmp实现ffmpeg转码rtsp为rtmp视频流
centos配置nginx-rtmp实现ffmpeg转码rtsp为rtmp视频流
132 1
|
16天前
|
Ubuntu 安全 应用服务中间件
详细指南:配置Nginx服务器在Ubuntu平台上
以上步骤涵盖了基本流程:从软件包管理器获取 Ngnix, 设置系统服务, 调整UFW规则, 创建并激活服务器块(也称作虚拟主机), 并进行了初步优化与加固措施。这些操作都是建立在命令行界面上,并假设用户具有必要权限(通常是root用户)来执行这些命令。每个操作都有其特定原因:例如,设置开机启动确保了即使重启后也能自动运行 Ngnix;而编辑server block则定义了如何处理进入特定域名请求等等。
157 18
|
18天前
|
Ubuntu 安全 应用服务中间件
详细指南:配置Nginx服务器在Ubuntu平台上
以上步骤涵盖了基本流程:从软件包管理器获取 Ngnix, 设置系统服务, 调整UFW规则, 创建并激活服务器块(也称作虚拟主机), 并进行了初步优化与加固措施。这些操作都是建立在命令行界面上,并假设用户具有必要权限(通常是root用户)来执行这些命令。每个操作都有其特定原因:例如,设置开机启动确保了即使重启后也能自动运行 Ngnix;而编辑server block则定义了如何处理进入特定域名请求等等。
147 17
|
20天前
|
Java 测试技术 数据安全/隐私保护
通过yaml文件配置自动化测试程序
通过yaml文件可以将自动化测试环境,测试数据和测试行为分开,请看一下案例
43 4
|
2月前
|
XML Ubuntu Java
如何在Ubuntu系统上安装和配置JMeter和Ant进行性能测试
进入包含 build.xml 的目录并执行:
117 13
|
2月前
|
数据建模 应用服务中间件 PHP
配置nginx容器和php容器协同工作成功,使用ip加端口的方式进行通信
本示例演示如何通过Docker挂载同一宿主目录至Nginx与PHP容器,实现PHP项目运行环境配置。需注意PHP容器中监听地址修改为0.0.0.0:9000,并调整Nginx配置中fastcgi_pass指向正确的IP与端口。同时确保Nginx容器中/var/www/html权限正确,以避免访问问题。
配置nginx容器和php容器协同工作成功,使用ip加端口的方式进行通信
|
3月前
|
应用服务中间件 网络安全 nginx
配置Nginx以支持Websocket连接的方法。
通过上述配置,Nginx将能够理解WebSocket协议的特殊要求,代理Websocket流量到合适的后端服务器。注意,Websocket并不是HTTP,尽管它最初是通过HTTP请求启动的连接升级,因此保证Nginx了解并能够妥善处理这种升级流程是关键。
571 10
|
2月前
|
Ubuntu 应用服务中间件 Linux
在Ubuntu上配置Nginx实现开机自启功能
至此,Nginx应该已经被正确地设置为开机自启。在Ubuntu中利用 `systemd`对服务进行管理是一种高效的方式,为系统管理员提供了强大的服务管理能力,包括但不限于启动、停止、重启服务,以及配置服务的开机自启动。通过这些简洁的命令,即使是对Linux不太熟悉的用户也能轻松地进行配置。
113 0
|
4月前
|
安全 应用服务中间件 网络安全
Nginx SSL/TLS协议栈中配置深度解析与实践指南-优雅草卓伊凡
Nginx SSL/TLS协议栈中配置深度解析与实践指南-优雅草卓伊凡
262 0
Nginx SSL/TLS协议栈中配置深度解析与实践指南-优雅草卓伊凡
|
4月前
|
JSON 前端开发 应用服务中间件
配置Nginx根据IP地址进行流量限制以及返回JSON格式数据的方案
最后,记得在任何生产环境部署之前,进行透彻测试以确保一切运转如预期。遵循这些战术,守卫你的网络城堡不再是难题。
196 3