中国投资网 百科 nginx配置负载均衡(防ddos攻击)

nginx配置负载均衡(防ddos攻击)

经常需要配置nginx,其中有许多以$开头的变量,经常需要查阅nginx所支持的变量。

可能是对Ngixn资源不熟悉,干脆就直接读源码,分析出支持的变量。

Nginx支持的超文本传送协议(超文本传输协议的缩写)变量实现在ngx _ http _变量。c的ngx _ http _核心_变量存储实现:

ngx _ http _核心_变量

一静态ngx _ http _ variable _ t ngx _ http _ core _ variables[]={

2

3 { ngx_string('http_host '),NULL,ngx_http_variable_header,

4 offsetof(ngx_http_request_t,headers_in.host),0,0 },

5

6 { ngx_string('http_user_agent '),NULL,ngx_http_variable_header,

7 offsetof(ngx_http_request_t,headers_in.user_agent),0,0 },

8

9 { ngx_string('http_referer '),NULL,ngx_http_variable_header,

10 offsetof(ngx_http_request_t,headers_in.referer),0,0 },

11

12 #if (NGX_HTTP_GZIP)

13 { ngx_string('http_via '),NULL,ngx_http_variable_header,

14 offsetof(ngx_http_request_t,headers_in.via),0,0 },

15 #endif

16

17 # if(NGX _ HTTP _ PROXY | | NGX _ HTTP _ REALIP)

18 { ngx _ string(' http _ x _ forwarded _ for '),NULL,ngx_http_variable_header,

19 offsetof(ngx_http_request_t,headers_in.x_forwarded_for),0,0 },

20 #endif

21

22 { ngx_string('http_cookie '),NULL,ngx_http_variable_headers,

23 offsetof(ngx_http_request_t,headers_in.cookies),0,0 },

24

25 { ngx_string('content_length '),NULL,ngx_http_variable_header,

26 offsetof(ngx_http_request_t,headers_in.content_length),0,0 },

27

28 { ngx_string('content_type '),NULL,ngx_http_variable_header,

29 offsetof(ngx_http_request_t,headers_in.content_type),0,0 },

30

31 { ngx_string('host '),NULL,ngx_http_variable_host,0,0,0 },

32

33 { ngx _ string(' binary _ remote _ addr '),NULL,

34 ngx _ http _变量_二进制_远程_地址,0,0,0 },

35

36 { ngx_string('remote_addr '),NULL,ngx_http_variable_remote_addr,0,0,0 },

37

38 { ngx_string('remote_port '),NULL,ngx_http_variable_remote_port,0,0,0 },

39

40 { ngx_string('server_addr '),NULL,ngx_http_variable_server_addr,0,0,0 },

41

42 { ngx_string('server_port '),NULL,ngx_http_variable_server_port,0,0,0 },

43

44 { ngx_string('server_protocol '),NULL,ngx_http_variable_request,

45 offsetof(ngx_http_request_t,http_protocol),0,0 },

46

47 { ngx_string('scheme '),NULL,ngx_http_variable_scheme,0,0,0 },

48

49 { ngx_string('request_uri '),NULL,ngx_http_variable_request,

50 offsetof(ngx_http_request_t,unparsed_uri),0,0 },

51

52 { ngx_string('uri '),NULL,ngx_http_variable_request,

53 offsetof(ngx_http_request_t,uri),

54 NGX_HTTP_VAR_NOCACHEABLE,0 },

55

56 { ngx_string('document_uri '),NULL,ngx_http_variable_request,

57 offsetof(ngx_http_request_t,uri),

58 NGX_HTTP_VAR_NOCACHEABLE,0 },

59

60 { ngx_string('request '),NULL,ngx_http_variable_request_line,0,0,0 },

61

62 { ngx_string('document_root '),NULL,

63 NGX _ HTTP _ variable _ document _ root,0,NGX_HTTP_VAR_NOCACHEABLE,0 },

64

65 { ngx_string('realpath_root '),NULL,

66 NGX _ HTTP _ variable _ real path _ root,0,NGX_HTTP_VAR_NOCACHEABLE,0 },

67

68 { ngx_string('query_string '),NULL,ngx_http_variable_request,

69 offsetof(ngx_http_request_t,args),

70 NGX_HTTP_VAR_NOCACHEABLE,0 },

71

72 { ngx_string('args '),

73 ngx _ http _ variable _ request _ set

74 ngx _ http _变量_请求,

75 offsetof(ngx_http_request_t,args),

76 NGX _ HTTP _ VAR _ changable | NGX _ HTTP _ VAR _ no cache able,0 },

77

78 { ngx_string('is_args '),NULL,ngx_http_variable_is_args,

79 0,NGX_HTTP_VAR_NOCACHEABLE,0 },

80

81 { ngx_string('请求_文件名'),空,

82 ngx _ http _变量_请求_文件名,0,

83 NGX_HTTP_VAR_NOCACHEABLE,0 },

84

85 { ngx_string('服务器名称'),NULL,ngx _ http _变量_服务器名称,0,0,0 }

86

87 { ngx_string('request_method '),NULL,

88 ngx _ http _变量_请求_方法,0,

89 NGX_HTTP_VAR_NOCACHEABLE,0 },

90

91 { ngx_string('remote_user '),NULL,ngx_http_variable_remote_user,0,0,0 },

92

93 { ngx_string('body_bytes_sent '),NULL,ngx _ http _ variable _ body _ bytes _ sent,

94 0, 0, 0 },

95

96 { ngx _ string(' request _ completion '),NULL,

97 ngx _ http _变量_请求_完成,

98 0, 0, 0 },

99

100 { ngx_string('request_body '),NULL,

101 ngx _ http _变量_请求_正文

102 0, 0, 0 },

103

104 { ngx _ string(' request _ body _ file '),NULL,

105 ngx _ http _变量_请求_正文_文件,

106 0, 0, 0 },

107

108 { ngx _ string(' sent _ http _ content _ type '),NULL,

109 ngx _ http _ variable _ sent _ content _ type,0,0,0 }

110

111 { ngx _ string(' sent _ http _ content _ length '),NULL,

112 ngx _ http _ variable _ sent _ content _ length,0,0,0 },

113

114 { ngx _ string(' sent _ http _ location '),NULL,

115 ngx _ http _变量_发送位置,0,0,0 }

116

117 { ngx _ string(' sent _ http _ last _ modified '),NULL,

118 ngx _ http _ variable _ sent _ last _ modified,0,0,0 },

119

120 { ngx _ string(' sent _ http _ connection '),NULL,

121 ngx _ http _变量_发送的连接,0,0,0 }

122

123 { ngx _ string(' sent _ http _ keep _ alive '),NULL,

124 ngx _ http _ variable _ sent _ keep _ alive,0,0,0 },

125

126 { ngx _ string(' sent _ http _ transfer _ encoding '),NULL,

127 ngx _ http _ variable _ sent _ transfer _ encoding,0,0,0 },

128

129 { ngx _ string(' sent _ http _ cache _ control '),NULL,ngx_http_variable_headers,

130 offsetof(ngx_http_request_t,headers_out.cache_control),0,0 },

131

132 { ngx_string('limit_rate '),ngx _ http _ variable _ request _ set _ size,

133 ngx _ http _变量_请求_获取_大小,

134 offsetof(ngx_http_request_t,limit_rate),

135 NGX _ HTTP _ VAR _ changable | NGX _ HTTP _ VAR _ no cache able,0 },

136

137 { ngx_string('nginx_version '),NULL,ngx _ http _ variable _ nginx _ version,

138 0, 0, 0 },

139

140 { ngx_string('hostname '),NULL,ngx_http_variable_hostname,

141 0, 0, 0 },

142

143 { ngx_string('pid '),NULL,ngx_http_variable_pid,

144 0, 0, 0 },

145

146 { ngx_null_string,null,null,0,0,0 }

147 };

把这些变量提取下,总结如下:

nginx配置负载均衡(防ddos攻击)

nginx配置负载均衡(防ddos攻击)

nginx配置负载均衡(防ddos攻击)

nginx防军械服务局副局长军火服务司副司长攻击的简单配置

nginx本身就有防军械服务局副局长军火服务司副司长攻击这方面的模块ngx _ http _ limit _ req _模块和ngx_http_limit_conn_module

一、基本介绍

1.ngx _ http _ limit _ req _模块

配置格式及说明:

设置一个缓存区保存不同键的状态,这里的状态是指当前的过量请求数。而键是由可变的指定的,是一个非空的变量,我们这里使用$binary_remote_addr,表示源互联网协议(互联网协议)为键值。

limit _ req _ zone $ variable zone=name:size rate=rate;

指定要进行限制的缓存区和最大的请求到达后有多少个请求放入延迟队列(其它的直接丢弃)。如果不希望请求

本文来自网络,不代表本站立场,转载请注明出处:https:

nginx配置负载均衡(防ddos攻击)

中国投资网后续将为您提供丰富、全面的关于nginx配置负载均衡(防ddos攻击)内容,让您第一时间了解到关于nginx配置负载均衡(防ddos攻击)的热门信息。小编将持续从百度新闻、搜狗百科、微博热搜、知乎热门问答以及部分合作站点渠道收集和补充完善信息。