nginx正向代理如何优化?
时间:2014-12-03 14:00 来源:linux.it.net.cn 作者:IT
把服务器A作为代理服务器,内网所有用户通过代理A访问外网(http协议,其他暂不考虑),现在已经能实现其基本功能,但是代理效果不好,开网页有点卡,请问如何提升nginx正向代理速度?
nginx.cnf如下
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
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name X.X.X.X;
#DNS 也用过国内的DNS,但开网页速度没有提升
resolver 8.8.8.8;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass $scheme://$http_host$request_uri;
proxy_set_header Host $http_host;
proxy_buffers 256 4K;
proxy_max_temp_file_size 0;
proxy_connect_timeout 30;
proxy_cache_valid 200 302 10m;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
(责任编辑:IT)
把服务器A作为代理服务器,内网所有用户通过代理A访问外网(http协议,其他暂不考虑),现在已经能实现其基本功能,但是代理效果不好,开网页有点卡,请问如何提升nginx正向代理速度? nginx.cnf如下
(责任编辑:IT) |