nginx常用配置项

nginx 一些常规配置项

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
http{
upstream upServer{
server 127.0.0.1:8001 weight=3;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
server 127.0.0.1:8004;
server 127.0.0.1:8005;
}

server{
listen 80;
server_name www.test.com;
access_log /var/log/web/test_access.log
error_log /var/log/web/test-error.log
location / {
root /data/wwwroot/testProject;
index index.html;
}
#反向代理设置
location /{
proxy_pass http://localhost:9000;
proxy_direct 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_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_send_lowat 12000;
client_max_body_size 10m;
client_body_buffer_size 128k;
gzip on;
gzip_types text/plain;
gzip_min_length 1100;
gzip_buffers 4 8k;
charset utf-8;
}
#错误页面自定义
error 404 /404.html;

location /404.html{
root /spool/www
}
#负载均衡
location / {
proxy_pass http://upServer
}
#支持php
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#防盗链
location ~* \.(gif|jpg|png|swf|flv)$ {
valid_referers none blocked *.nginxcn.com;
if ($invalid_referer) {
rewrite ^/ [www.nginx.cn](http://www.nginx.cn/)
#return 404;
}
}
}
}
你是本站第位访客 本站访客数人次
Fork me on GitHub