Browse Source

nginx: import from packages, add myself as the maintainer

This adds the nginx package from the old svn package fee. I adopt
the licensing information and will maintain the package in the future.
This request also updates nginx to the last stable version 1.4.7. It further
adds support for
 - naxsi (the ngix web application firewall)
 - syslog module
 - http upstream check module
 - support for the haproxy Proxy Protocol (this way nginx can see the real
   ip address behind haproxy)
Building was tested with target x86_64, ar71xx and avr32.

Signed-off-by: Thomas Heil <heil@terminal-consulting.de>
Thomas Heil 10 years ago
parent
commit
e9da522f68

+ 187
- 0
net/nginx/Config.in View File

@@ -0,0 +1,187 @@
1
+#
2
+# Copyright (C) 2010-2012 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+menu "Configuration"
9
+        depends on PACKAGE_nginx
10
+
11
+config NGINX_STUB_STATUS
12
+	bool
13
+	prompt "Enable stub status module"
14
+	help
15
+		Enable the stub status module which gives some status from the server.
16
+
17
+config NGINX_FLV
18
+	bool
19
+	prompt "Enable FLV module"
20
+	help
21
+		Provides the ability to seek within FLV (Flash) files using time-based offsets.
22
+
23
+config NGINX_SSL
24
+	bool
25
+	prompt "Enable SSL module"
26
+	help
27
+		Enable HTTPS/SSL support.
28
+
29
+config NGINX_DAV
30
+	bool
31
+	prompt "Enable WebDAV module"
32
+	help
33
+		Enable the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and MOVE.
34
+
35
+config NGINX_LUA
36
+	bool
37
+	prompt "Enable LUA module"
38
+	help
39
+		Enable support for LUA scripts.
40
+
41
+config NGINX_PCRE
42
+	bool
43
+	prompt "Enable PCRE library usage"
44
+	default y
45
+
46
+config NGINX_HTTP_CACHE
47
+	bool
48
+	prompt "Enable HTTP cache"
49
+
50
+config NGINX_HTTP_CHARSET
51
+	bool
52
+	prompt "Enable HTTP charset module"
53
+	default y
54
+
55
+config NGINX_HTTP_GZIP
56
+	bool
57
+	prompt "Enable HTTP gzip module"
58
+	default y
59
+
60
+config NGINX_HTTP_SSI
61
+	bool
62
+	prompt "Enable HTTP ssi module"
63
+	default y
64
+
65
+config NGINX_HTTP_USERID
66
+	bool
67
+	prompt "Enable HTTP userid module"
68
+	default y
69
+
70
+config NGINX_HTTP_ACCESS
71
+	bool
72
+	prompt "Enable HTTP access module"
73
+	default y
74
+
75
+config NGINX_HTTP_AUTH_BASIC
76
+	bool
77
+	prompt "Enable HTTP auth basic"
78
+	default y
79
+
80
+config NGINX_HTTP_AUTOINDEX
81
+	bool
82
+	prompt "Enable HTTP autoindex module"
83
+	default y
84
+
85
+config NGINX_HTTP_GEO
86
+	bool
87
+	prompt "Enable HTTP geo module"
88
+	default y
89
+
90
+config NGINX_HTTP_MAP
91
+	bool
92
+	prompt "Enable HTTP map module"
93
+	default y
94
+
95
+config NGINX_HTTP_SPLIT_CLIENTS
96
+	bool
97
+	prompt "Enable HTTP split clients"
98
+	default y
99
+
100
+config NGINX_HTTP_REFERER
101
+	bool
102
+	prompt "Enable HTTP referer module"
103
+	default y
104
+
105
+config NGINX_HTTP_REWRITE
106
+	bool
107
+	prompt "Enable HTTP rewrite module"
108
+	select NGINX_PCRE
109
+	default y
110
+
111
+config NGINX_HTTP_PROXY
112
+	bool
113
+	prompt "Enable HTTP proxy module"
114
+	default y
115
+
116
+config NGINX_HTTP_FASTCGI
117
+	bool
118
+	prompt "Enable HTTP fastcgi module"
119
+	default y
120
+
121
+config NGINX_HTTP_UWSGI
122
+	bool
123
+	prompt "Enable HTTP uwsgi module"
124
+	default y
125
+
126
+config NGINX_HTTP_SCGI
127
+	bool
128
+	prompt "Enable HTTP scgi module"
129
+	default y
130
+
131
+config NGINX_HTTP_MEMCACHED
132
+	bool
133
+	prompt "Enable HTTP memcached module"
134
+	default y
135
+
136
+config NGINX_HTTP_LIMIT_CONN
137
+	bool
138
+	prompt "Enable HTTP limit conn"
139
+	default y
140
+
141
+config NGINX_HTTP_LIMIT_REQ
142
+	bool
143
+	prompt "Enable HTTP limit req"
144
+	default y
145
+
146
+config NGINX_HTTP_EMPTY_GIF
147
+	bool
148
+	prompt "Enable HTTP empty gif"
149
+	default y
150
+
151
+config NGINX_HTTP_BROWSER
152
+	bool
153
+	prompt "Enable HTTP browser module"
154
+	default y
155
+
156
+config NGINX_HTTP_UPSTREAM_IP_HASH
157
+	bool
158
+	prompt "Enable HTTP IP hash module"
159
+	default y
160
+
161
+config NGINX_NAXSI
162
+	bool
163
+	prompt "Enable NAXSI module"
164
+	select PACKAGE_nginx-naxsi
165
+	help
166
+		Enable support for NAXSI WAF.
167
+
168
+config NGINX_PROXYPROTOCOL
169
+	bool
170
+	prompt "Enable NAXSI proxyprotocol"
171
+	select PACKAGE_nginx-proxyprotocol
172
+	help
173
+		Enable support for NAXSI WAF.
174
+
175
+config NGINX_SYSLOG
176
+	bool
177
+	prompt "Enable Syslog module"
178
+	select PACKAGE_nginx-syslog
179
+	help
180
+		Provides the ability log to a remote destination
181
+
182
+config NGINX_HTTP_UPSTREAM_CHECK
183
+	bool
184
+	prompt "Enable HTTP upstream check module"
185
+	default y
186
+
187
+endmenu

+ 334
- 0
net/nginx/Makefile View File

@@ -0,0 +1,334 @@
1
+#
2
+# Copyright (C) 2009-2012 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=nginx
11
+PKG_VERSION:=1.4.7
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15
+PKG_SOURCE_URL:=http://nginx.org/download/
16
+PKG_MD5SUM:=aee151d298dcbfeb88b3f7dd3e7a4d17
17
+PKG_MAINTAINER:=Thomas Heil <heil@terminal-consulting.de>
18
+PKG_LICENSE:=2-clause BSD-like license
19
+
20
+PKG_BUILD_PARALLEL:=1
21
+PKG_INSTALL:=1
22
+
23
+PKG_CONFIG_DEPENDS := \
24
+	CONFIG_NGINX_STUB_STATUS \
25
+	CONFIG_NGINX_FLV \
26
+	CONFIG_NGINX_SSL \
27
+	CONFIG_NGINX_DAV \
28
+	CONFIG_NGINX_LUA \
29
+	CONFIG_NGINX_PCRE \
30
+	CONFIG_NGINX_HTTP_CACHE \
31
+	CONFIG_NGINX_HTTP_CHARSET \
32
+	CONFIG_NGINX_HTTP_GZIP \
33
+	CONFIG_NGINX_HTTP_SSI \
34
+	CONFIG_NGINX_HTTP_USERID \
35
+	CONFIG_NGINX_HTTP_ACCESS \
36
+	CONFIG_NGINX_HTTP_AUTH_BASIC \
37
+	CONFIG_NGINX_HTTP_AUTOINDEX \
38
+	CONFIG_NGINX_HTTP_GEO \
39
+	CONFIG_NGINX_HTTP_MAP \
40
+	CONFIG_NGINX_HTTP_SPLIT_CLIENTS \
41
+	CONFIG_NGINX_HTTP_REFERER \
42
+	CONFIG_NGINX_HTTP_REWRITE \
43
+	CONFIG_NGINX_HTTP_PROXY \
44
+	CONFIG_NGINX_HTTP_FASTCGI \
45
+	CONFIG_NGINX_HTTP_UWSGI \
46
+	CONFIG_NGINX_HTTP_SCGI \
47
+	CONFIG_NGINX_HTTP_MEMCACHED \
48
+	CONFIG_NGINX_HTTP_LIMIT_CONN \
49
+	CONFIG_NGINX_HTTP_LIMIT_REQ \
50
+	CONFIG_NGINX_HTTP_EMPTY_GIF \
51
+	CONFIG_NGINX_HTTP_BROWSER \
52
+	CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH
53
+
54
+include $(INCLUDE_DIR)/package.mk
55
+
56
+define Package/nginx
57
+  SECTION:=net
58
+  CATEGORY:=Network
59
+  SUBMENU:=Web Servers/Proxies
60
+  TITLE:=Nginx web server
61
+  URL:=http://nginx.org/
62
+  DEPENDS:=+NGINX_PCRE:libpcre +(NGINX_SSL||NGINX_HTTP_CACHE||NGINX_HTTP_AUTH_BASIC):libopenssl +NGINX_HTTP_GZIP:zlib +libpthread +NGINX_LUA:liblua
63
+  MENU:=1
64
+endef
65
+
66
+define Package/nginx/description
67
+ nginx is an HTTP and reverse proxy server, as well as a mail proxy server,
68
+ written by Igor Sysoev.
69
+endef
70
+
71
+define Package/nginx/config
72
+  source "$(SOURCE)/Config.in"
73
+endef
74
+
75
+config_files=nginx.conf mime.types fastcgi_params koi-utf koi-win win-utf
76
+
77
+define Package/nginx/conffiles
78
+/etc/nginx/
79
+endef
80
+
81
+ADDITIONAL_MODULES:=
82
+ifeq ($(CONFIG_NGINX_NAXSI),y)
83
+  ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src
84
+endif
85
+ifeq ($(CONFIG_IPV6),y)
86
+  ADDITIONAL_MODULES += --with-ipv6
87
+endif
88
+ifeq ($(CONFIG_NGINX_STUB_STATUS),y)
89
+  ADDITIONAL_MODULES += --with-http_stub_status_module
90
+endif
91
+ifeq ($(CONFIG_NGINX_FLV),y)
92
+  ADDITIONAL_MODULES += --with-http_flv_module
93
+endif
94
+ifeq ($(CONFIG_NGINX_SSL),y)
95
+  ADDITIONAL_MODULES += --with-http_ssl_module
96
+endif
97
+ifeq ($(CONFIG_NGINX_DAV),y)
98
+  ADDITIONAL_MODULES += --with-http_dav_module
99
+endif
100
+ifeq ($(CONFIG_NGINX_LUA),y)
101
+  ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/lua-nginx
102
+endif
103
+ifneq ($(CONFIG_NGINX_HTTP_CACHE),y)
104
+  ADDITIONAL_MODULES += --without-http-cache
105
+endif
106
+ifneq ($(CONFIG_NGINX_PCRE),y)
107
+  ADDITIONAL_MODULES += --without-pcre
108
+endif
109
+ifneq ($(CONFIG_NGINX_HTTP_CHARSET),y)
110
+  ADDITIONAL_MODULES += --without-http_charset_module
111
+endif
112
+ifneq ($(CONFIG_NGINX_HTTP_GZIP),y)
113
+  ADDITIONAL_MODULES += --without-http_gzip_module
114
+endif
115
+ifneq ($(CONFIG_NGINX_HTTP_SSI),y)
116
+  ADDITIONAL_MODULES += --without-http_ssi_module
117
+endif
118
+ifneq ($(CONFIG_NGINX_HTTP_USERID),y)
119
+  ADDITIONAL_MODULES += --without-http_userid_module
120
+endif
121
+ifneq ($(CONFIG_NGINX_HTTP_ACCESS),y)
122
+  ADDITIONAL_MODULES += --without-http_access_module
123
+endif
124
+ifneq ($(CONFIG_NGINX_HTTP_AUTH_BASIC),y)
125
+  ADDITIONAL_MODULES += --without-http_auth_basic_module
126
+endif
127
+ifneq ($(CONFIG_NGINX_HTTP_AUTOINDEX),y)
128
+  ADDITIONAL_MODULES += --without-http_autoindex_module
129
+endif
130
+ifneq ($(CONFIG_NGINX_HTTP_GEO),y)
131
+  ADDITIONAL_MODULES += --without-http_geo_module
132
+endif
133
+ifneq ($(CONFIG_NGINX_HTTP_MAP),y)
134
+  ADDITIONAL_MODULES += --without-http_map_module
135
+endif
136
+ifneq ($(CONFIG_NGINX_HTTP_SPLIT_CLIENTS),y)
137
+  ADDITIONAL_MODULES += --without-http_split_clients_module
138
+endif
139
+ifneq ($(CONFIG_NGINX_HTTP_REFERER),y)
140
+  ADDITIONAL_MODULES += --without-http_referer_module
141
+endif
142
+ifneq ($(CONFIG_NGINX_HTTP_REWRITE),y)
143
+  ADDITIONAL_MODULES += --without-http_rewrite_module
144
+endif
145
+ifneq ($(CONFIG_NGINX_HTTP_PROXY),y)
146
+  ADDITIONAL_MODULES += --without-http_proxy_module
147
+endif
148
+ifneq ($(CONFIG_NGINX_HTTP_FASTCGI),y)
149
+  ADDITIONAL_MODULES += --without-http_fastcgi_module
150
+endif
151
+ifneq ($(CONFIG_NGINX_HTTP_UWSGI),y)
152
+  ADDITIONAL_MODULES += --without-http_uwsgi_module
153
+endif
154
+ifneq ($(CONFIG_NGINX_HTTP_SCGI),y)
155
+  ADDITIONAL_MODULES += --without-http_scgi_module
156
+endif
157
+ifneq ($(CONFIG_NGINX_HTTP_MEMCACHED),y)
158
+  ADDITIONAL_MODULES += --without-http_memcached_module
159
+endif
160
+ifneq ($(CONFIG_NGINX_HTTP_LIMIT_CONN),y)
161
+  ADDITIONAL_MODULES += --without-http_limit_conn_module
162
+endif
163
+ifneq ($(CONFIG_NGINX_HTTP_LIMIT_REQ),y)
164
+  ADDITIONAL_MODULES += --without-http_limit_req_module
165
+endif
166
+ifneq ($(CONFIG_NGINX_HTTP_EMPTY_GIF),y)
167
+  ADDITIONAL_MODULES += --without-http_empty_gif_module
168
+endif
169
+ifneq ($(CONFIG_NGINX_HTTP_BROWSER),y)
170
+  ADDITIONAL_MODULES += --without-http_browser_module
171
+endif
172
+ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH),y)
173
+  ADDITIONAL_MODULES += --without-http_upstream_ip_hash_module
174
+endif
175
+ifeq ($(CONFIG_NGINX_PROXYPROTOCOL),y)
176
+  ADDITIONAL_MODULES += --with-proxy-protocol
177
+endif
178
+ifeq ($(CONFIG_NGINX_SYSLOG),y)
179
+  ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-syslog
180
+endif
181
+ifeq ($(CONFIG_NGINX_HTTP_UPSTREAM_CHECK),y)
182
+  ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-upstream-check
183
+endif
184
+
185
+define Build/Configure
186
+	# TODO: fix --crossbuild
187
+	(cd $(PKG_BUILD_DIR) ;\
188
+		$(if $(CONFIG_NGINX_LUA),LUA_INC=$(STAGING_DIR)/usr/include LUA_LIB=$(STAGING_DIR)/usr/lib) \
189
+		./configure \
190
+			--crossbuild=Linux::$(ARCH) \
191
+			--prefix=/usr \
192
+			--conf-path=/etc/nginx/nginx.conf \
193
+			$(ADDITIONAL_MODULES) \
194
+			--error-log-path=/var/log/nginx/error.log \
195
+			--pid-path=/var/run/nginx.pid \
196
+			--lock-path=/var/lock/nginx.lock \
197
+			--http-log-path=/var/log/nginx/access.log \
198
+			--http-client-body-temp-path=/var/lib/nginx/body \
199
+			--http-proxy-temp-path=/var/lib/nginx/proxy \
200
+			--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
201
+			--with-cc="$(TARGET_CC)" \
202
+			--with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
203
+			--with-ld-opt="$(TARGET_LDFLAGS)" )
204
+endef
205
+
206
+define Package/nginx/install
207
+	$(INSTALL_DIR) $(1)/usr/sbin
208
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/
209
+	$(INSTALL_DIR) $(1)/etc/nginx
210
+	$(INSTALL_DATA) $(addprefix $(PKG_INSTALL_DIR)/etc/nginx/,$(config_files)) $(1)/etc/nginx/
211
+	$(INSTALL_DIR) $(1)/etc/init.d
212
+	$(INSTALL_BIN) ./files/nginx.init $(1)/etc/init.d/nginx
213
+endef
214
+
215
+define Build/Prepare
216
+	$(call Build/Prepare/Default)
217
+	$(if $(CONFIG_NGINX_LUA),$(call Prepare/lua-nginx))
218
+	$(if $(CONFIG_NGINX_NAXSI),$(call Prepare/nginx-naxsi))
219
+	$(if $(CONFIG_NGINX_SYSLOG),$(call Prepare/nginx-syslog))
220
+	$(if $(CONFIG_NGINX_HTTP_UPSTREAM_CHECK),$(call Prepare/nginx-upstream-check))
221
+endef
222
+
223
+define Download/lua-nginx
224
+	VERSION:=d3ab0edd45bffe1b9a36abdf5bff544de436ccee
225
+	SUBDIR:=lua-nginx
226
+	FILE:=lua-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz
227
+	URL:=https://github.com/chaoslawful/lua-nginx-module.git
228
+	PROTO:=git
229
+endef
230
+
231
+define  Prepare/lua-nginx
232
+	$(eval $(call Download,lua-nginx))
233
+	gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
234
+	$(call PatchDir,$(PKG_BUILD_DIR),./patches-lua-nginx)
235
+endef
236
+
237
+define Download/nginx-upstream-check
238
+	VERSION:=d40b9f956d9d978005bb15616d2f283d4e3d2031
239
+	SUBDIR:=nginx-upstream-check
240
+	FILE:=nginx-upstream-check-$(PKG_VERSION)-$$(VERSION).tar.gz
241
+	URL:=https://github.com/yaoweibin/nginx_upstream_check_module.git
242
+	PROTO:=git
243
+endef
244
+
245
+define  Prepare/nginx-upstream-check
246
+	$(eval $(call Download,nginx-upstream-check))
247
+	gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
248
+	$(call PatchDir,$(PKG_BUILD_DIR),./patches-nginx-upstream-check)
249
+endef
250
+
251
+
252
+define Package/nginx-naxsi
253
+        MENU:=1
254
+        $(call Package/nginx)
255
+        TITLE+= nginx-naxsi
256
+        DEPENDS:=nginx
257
+endef
258
+
259
+define Package/nginx-naxsi/description
260
+        NGINX WAF NAXSI
261
+endef
262
+
263
+define Package/nginx-proxyprotocol
264
+        MENU:=1
265
+        $(call Package/nginx)
266
+        TITLE+= nginx-proxyprotocol
267
+        DEPENDS:=nginx
268
+endef
269
+
270
+define Package/nginx-proxyprotocol/description
271
+        IMPLEMENT Proxy Protocol
272
+endef
273
+
274
+define Package/nginx-syslog
275
+        MENU:=1
276
+        $(call Package/nginx)
277
+        TITLE+= nginx-syslog
278
+        DEPENDS:=nginx
279
+endef
280
+
281
+define Package/nginx-syslog/description
282
+        IMPLEMENT Syslog Protocol
283
+endef
284
+
285
+define Download/nginx-naxsi
286
+	VERSION:=34dcb45fe4fdcb144c5258d83672f8e1e1c8db2e
287
+	SUBDIR:=nginx-naxsi
288
+	FILE:=nginx-naxsi-module-$(PKG_VERSION)-$$(VERSION).tar.gz
289
+	URL:=https://github.com/nbs-system/naxsi.git
290
+	PROTO:=git
291
+endef
292
+
293
+define  Prepare/nginx-naxsi
294
+	$(eval $(call Download,nginx-naxsi))
295
+	gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
296
+endef
297
+
298
+define Package/nginx-naxsi/install
299
+	$(INSTALL_DIR) $(1)/etc/nginx
300
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx
301
+	chmod 0640 $(1)/etc/nginx/naxsi_core.rules
302
+endef
303
+
304
+define Download/nginx-syslog
305
+	VERSION:=7abf48e52552c40a21463e1a8c608e0e575261cd
306
+	SUBDIR:=nginx-syslog
307
+	FILE:=nginx-syslog-module-$(PKG_VERSION)-$$(VERSION).tar.gz
308
+	URL:=https://github.com/splitice/nginx_syslog_patch.git
309
+	PROTO:=git
310
+endef
311
+
312
+define  Prepare/nginx-syslog
313
+	$(eval $(call Download,nginx-syslog))
314
+	gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
315
+endef
316
+
317
+define Package/nginx-proxyprotocol/install
318
+	$(INSTALL_DIR) $(1)/etc/nginx
319
+	$(INSTALL_BIN) ./files/nginx.proxyprotocol.example $(1)/etc/nginx/nginx.conf.proxyprotocol
320
+	chmod 0640 $(1)/etc/nginx/nginx.conf.proxyprotocol
321
+endef
322
+
323
+define Package/nginx-syslog/install
324
+	$(INSTALL_DIR) $(1)/etc/nginx
325
+	$(INSTALL_BIN) ./files/nginx.syslog.example $(1)/etc/nginx/nginx.conf.syslog
326
+	chmod 0640 $(1)/etc/nginx/nginx.conf.syslog
327
+endef
328
+
329
+
330
+$(eval $(call BuildPackage,nginx))
331
+$(eval $(call BuildPackage,nginx-naxsi))
332
+$(eval $(call BuildPackage,nginx-proxyprotocol))
333
+$(eval $(call BuildPackage,nginx-syslog))
334
+

+ 24
- 0
net/nginx/files/nginx.init View File

@@ -0,0 +1,24 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2009-2012 OpenWrt.org
3
+
4
+START=50
5
+NGINX_BIN=/usr/sbin/nginx
6
+
7
+start() {
8
+	mkdir -p /var/log/nginx
9
+	mkdir -p /var/lib/nginx
10
+	$NGINX_BIN
11
+}
12
+
13
+stop() {
14
+	$NGINX_BIN -s stop
15
+}
16
+
17
+reload() {
18
+	$NGINX_BIN -s reload
19
+}
20
+
21
+shutdown() {
22
+	$NGINX_BIN -s quit
23
+}
24
+

+ 40
- 0
net/nginx/files/nginx.proxyprotocol.example View File

@@ -0,0 +1,40 @@
1
+worker_processes  1;
2
+pid /tmp/nginx.pid;
3
+daemon off;
4
+master_process off;
5
+error_log stderr debug_core;
6
+
7
+events {
8
+ debug_connection <YOUR IPv4>;
9
+ debug_connection <YOUR IPV6>;
10
+ worker_connections  1024;
11
+}
12
+
13
+http {
14
+ default_type  application/octet-stream;
15
+ client_body_temp_path /tmp/body 1;
16
+
17
+ access_log /tmp/nginx_access.log;
18
+
19
+ server {
20
+#  listen       8082 ssl;
21
+# proxy protocol configuration for nginx 1.4.x:
22
+  listen       8082 accept_proxy_protocol=on;
23
+# same with spdy enabled:
24
+#  listen       8082 spdy ssl accept_proxy_protocol=on;
25
+  listen       [::]:8082 ipv6only=on;
26
+  ssl_certificate /your/certificate;
27
+  ssl_certificate_key /your/key;
28
+  server_name  localhost;
29
+# proxy protocol configuration for nginx 1.2.x:
30
+#  accept_proxy_protocol on;
31
+ 
32
+  location / {
33
+   proxy_pass        http://127.0.0.1:8084;
34
+   proxy_set_header  X-Real-IP  $remote_addr;
35
+   proxy_connect_timeout 10s;
36
+   proxy_read_timeout 10s;
37
+   send_proxy_protocol on;
38
+  }
39
+ }
40
+}

+ 59
- 0
net/nginx/files/nginx.syslog.example View File

@@ -0,0 +1,59 @@
1
+worker_processes  1;
2
+
3
+syslog local6 nginx;
4
+
5
+events {
6
+        worker_connections  1024;
7
+}
8
+
9
+http {
10
+    include       mime.types;
11
+    default_type  application/octet-stream;
12
+
13
+    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
14
+        '"$status" $body_bytes_sent "$http_referer" '
15
+        '"$http_user_agent" "$http_x_forwarded_for"';
16
+
17
+    server {
18
+        listen       80;
19
+        server_name  localhost;
20
+
21
+        #send the log to syslog and file.
22
+        access_log  syslog:notice|logs/host1.access.log main;
23
+
24
+        # pre 1.5.x
25
+        error_log syslog:notice|logs/host1.error.log;
26
+
27
+        location / {
28
+            root   html;
29
+            index  index.html index.htm;
30
+        }
31
+    }
32
+
33
+    server {
34
+        listen       80;
35
+        server_name  www.example.com;
36
+
37
+        access_log  syslog:warn|logs/host2.access.log main;
38
+        error_log syslog:warn|logs/host2.error.log;
39
+
40
+        location / {
41
+            root   html;
42
+            index  index.html index.htm;
43
+        }
44
+    }
45
+
46
+    server {
47
+        listen       80;
48
+        server_name  www.test.com;
49
+
50
+        #send the log just to syslog.
51
+        access_log  syslog:error main;
52
+        error_log syslog:error;
53
+
54
+        location / {
55
+            root   html;
56
+            index  index.html index.htm;
57
+        }
58
+    }
59
+}

+ 21
- 0
net/nginx/patches-lua-nginx/300-ldl.patch View File

@@ -0,0 +1,21 @@
1
+--- a/lua-nginx/config
2
++++ b/lua-nginx/config
3
+@@ -1,5 +1,5 @@
4
+ ngx_feature="Lua library"
5
+-ngx_feature_libs="-llua -lm"
6
++ngx_feature_libs="-llua -lm -ldl"
7
+ ngx_feature_name=
8
+ ngx_feature_run=no
9
+ ngx_feature_incs="#include <lauxlib.h>"
10
+@@ -47,9 +47,9 @@ else
11
+         ngx_feature="Lua library in $LUA_LIB and $LUA_INC (specified by the LUA_LIB and LUA_INC env)"
12
+         ngx_feature_path="$LUA_INC"
13
+         if [ $NGX_RPATH = YES ]; then
14
+-            ngx_feature_libs="-R$LUA_LIB -L$LUA_LIB -llua -lm"
15
++            ngx_feature_libs="-R$LUA_LIB -L$LUA_LIB -llua -lm -ldl"
16
+         else
17
+-            ngx_feature_libs="-L$LUA_LIB -llua -lm"
18
++            ngx_feature_libs="-L$LUA_LIB -llua -lm -ldl"
19
+         fi
20
+ 
21
+         . auto/feature

+ 209
- 0
net/nginx/patches-nginx-upstream-check/check_1.2.6+.patch View File

@@ -0,0 +1,209 @@
1
+diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
2
+index 89ccc2b..a552044 100644
3
+--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
4
++++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
5
+@@ -9,6 +9,10 @@
6
+ #include <ngx_core.h>
7
+ #include <ngx_http.h>
8
+ 
9
++#if (NGX_UPSTREAM_CHECK_MODULE)
10
++#include "ngx_http_upstream_check_handler.h"
11
++#endif
12
++
13
+ 
14
+ typedef struct {
15
+     /* the round robin data must be first */
16
+@@ -208,6 +212,12 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
17
+ 
18
+             if (!peer->down) {
19
+ 
20
++#if (NGX_UPSTREAM_CHECK_MODULE)
21
++                ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
22
++                               "get ip_hash peer, check_index: %ui",
23
++                               peer->check_index);
24
++                if (!ngx_http_check_peer_down(peer->check_index)) {
25
++#endif
26
+                 if (peer->max_fails == 0 || peer->fails < peer->max_fails) {
27
+                     break;
28
+                 }
29
+@@ -216,6 +226,9 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
30
+                     peer->checked = now;
31
+                     break;
32
+                 }
33
++#if (NGX_UPSTREAM_CHECK_MODULE)
34
++                }
35
++#endif
36
+             }
37
+ 
38
+             iphp->rrp.tried[n] |= m;
39
+diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c b/src/http/modules/ngx_http_upstream_least_conn_module.c
40
+index 21156ae..c57393d 100644
41
+--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
42
++++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
43
+@@ -9,6 +9,10 @@
44
+ #include <ngx_core.h>
45
+ #include <ngx_http.h>
46
+ 
47
++#if (NGX_UPSTREAM_CHECK_MODULE)
48
++#include "ngx_http_upstream_check_handler.h"
49
++#endif
50
++
51
+ 
52
+ typedef struct {
53
+     ngx_uint_t                        *conns;
54
+@@ -203,6 +207,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
55
+             continue;
56
+         }
57
+ 
58
++#if (NGX_UPSTREAM_CHECK_MODULE)
59
++        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
60
++                "get least_conn peer, check_index: %ui",
61
++                peer->check_index);
62
++
63
++        if (ngx_http_check_peer_down(peer->check_index)) {
64
++            continue;
65
++        }
66
++#endif
67
++
68
+         if (peer->max_fails
69
+             && peer->fails >= peer->max_fails
70
+             && now - peer->checked <= peer->fail_timeout)
71
+@@ -256,6 +270,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
72
+                 continue;
73
+             }
74
+ 
75
++#if (NGX_UPSTREAM_CHECK_MODULE)
76
++            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
77
++                    "get least_conn peer, check_index: %ui",
78
++                    peer->check_index);
79
++
80
++            if (ngx_http_check_peer_down(peer->check_index)) {
81
++                continue;
82
++            }
83
++#endif
84
++
85
+             if (lcp->conns[i] * best->weight != lcp->conns[p] * peer->weight) {
86
+                 continue;
87
+             }
88
+diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
89
+index 4b78cff..f077b46 100644
90
+--- a/src/http/ngx_http_upstream_round_robin.c
91
++++ b/src/http/ngx_http_upstream_round_robin.c
92
+@@ -9,6 +9,9 @@
93
+ #include <ngx_core.h>
94
+ #include <ngx_http.h>
95
+ 
96
++#if (NGX_UPSTREAM_CHECK_MODULE)
97
++#include "ngx_http_upstream_check_handler.h"
98
++#endif
99
+ 
100
+ static ngx_int_t ngx_http_upstream_cmp_servers(const void *one,
101
+     const void *two);
102
+@@ -87,7 +90,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
103
+                 peers->peer[n].weight = server[i].weight;
104
+                 peers->peer[n].effective_weight = server[i].weight;
105
+                 peers->peer[n].current_weight = 0;
106
+-                n++;
107
++
108
++#if (NGX_UPSTREAM_CHECK_MODULE)
109
++                if (!server[i].down) {
110
++                    peers->peer[n].check_index =
111
++                        ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
112
++                }
113
++                else {
114
++                    peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
115
++                }
116
++#endif
117
++               n++;
118
+             }
119
+         }
120
+ 
121
+@@ -145,6 +158,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
122
+                 backup->peer[n].max_fails = server[i].max_fails;
123
+                 backup->peer[n].fail_timeout = server[i].fail_timeout;
124
+                 backup->peer[n].down = server[i].down;
125
++
126
++#if (NGX_UPSTREAM_CHECK_MODULE)
127
++                if (!server[i].down) {
128
++                    backup->peer[n].check_index =
129
++                        ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
130
++                }
131
++                else {
132
++                    backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
133
++                }
134
++#endif
135
++
136
+                 n++;
137
+             }
138
+         }
139
+@@ -206,6 +230,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
140
+         peers->peer[i].current_weight = 0;
141
+         peers->peer[i].max_fails = 1;
142
+         peers->peer[i].fail_timeout = 10;
143
++#if (NGX_UPSTREAM_CHECK_MODULE)
144
++        peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
145
++#endif
146
+     }
147
+ 
148
+     us->peer.data = peers;
149
+@@ -323,6 +350,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
150
+         peers->peer[0].current_weight = 0;
151
+         peers->peer[0].max_fails = 1;
152
+         peers->peer[0].fail_timeout = 10;
153
++#if (NGX_UPSTREAM_CHECK_MODULE)
154
++        peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR;
155
++#endif
156
+ 
157
+     } else {
158
+ 
159
+@@ -356,6 +386,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
160
+             peers->peer[i].current_weight = 0;
161
+             peers->peer[i].max_fails = 1;
162
+             peers->peer[i].fail_timeout = 10;
163
++#if (NGX_UPSTREAM_CHECK_MODULE)
164
++            peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
165
++#endif
166
+         }
167
+     }
168
+ 
169
+@@ -434,6 +467,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
170
+             goto failed;
171
+         }
172
+ 
173
++#if (NGX_UPSTREAM_CHECK_MODULE)
174
++        if (ngx_http_check_peer_down(peer->check_index)) {
175
++            goto failed;
176
++        }
177
++#endif
178
++
179
+     } else {
180
+ 
181
+         /* there are several peers */
182
+@@ -531,6 +570,12 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp)
183
+             continue;
184
+         }
185
+ 
186
++#if (NGX_UPSTREAM_CHECK_MODULE)
187
++        if (ngx_http_check_peer_down(peer->check_index)) {
188
++            continue;
189
++        }
190
++#endif
191
++
192
+         if (peer->max_fails
193
+             && peer->fails >= peer->max_fails
194
+             && now - peer->checked <= peer->fail_timeout)
195
+diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
196
+index 3f8cbf8..1613168 100644
197
+--- a/src/http/ngx_http_upstream_round_robin.h
198
++++ b/src/http/ngx_http_upstream_round_robin.h
199
+@@ -30,6 +30,10 @@ typedef struct {
200
+     ngx_uint_t                      max_fails;
201
+     time_t                          fail_timeout;
202
+ 
203
++#if (NGX_UPSTREAM_CHECK_MODULE)
204
++    ngx_uint_t                      check_index;
205
++#endif
206
++
207
+     ngx_uint_t                      down;          /* unsigned  down:1; */
208
+ 
209
+ #if (NGX_HTTP_SSL)

+ 107
- 0
net/nginx/patches/101-feature_test_fix.patch View File

@@ -0,0 +1,107 @@
1
+--- a/auto/cc/name
2
++++ b/auto/cc/name
3
+@@ -7,7 +7,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
4
+ 
5
+     ngx_feature="C compiler"
6
+     ngx_feature_name=
7
+-    ngx_feature_run=yes
8
++    ngx_feature_run=
9
+     ngx_feature_incs=
10
+     ngx_feature_path=
11
+     ngx_feature_libs=
12
+--- a/auto/cc/conf
13
++++ b/auto/cc/conf
14
+@@ -155,7 +155,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
15
+     else
16
+         ngx_feature="C99 variadic macros"
17
+         ngx_feature_name="NGX_HAVE_C99_VARIADIC_MACROS"
18
+-        ngx_feature_run=yes
19
++        ngx_feature_run=no
20
+         ngx_feature_incs="#include <stdio.h>
21
+ #define var(dummy, ...)  sprintf(__VA_ARGS__)"
22
+         ngx_feature_path=
23
+@@ -169,7 +169,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
24
+ 
25
+     ngx_feature="gcc variadic macros"
26
+     ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
27
+-    ngx_feature_run=yes
28
++    ngx_feature_run=no
29
+     ngx_feature_incs="#include <stdio.h>
30
+ #define var(dummy, args...)  sprintf(args)"
31
+     ngx_feature_path=
32
+--- a/auto/os/linux
33
++++ b/auto/os/linux
34
+@@ -48,7 +48,7 @@ fi
35
+ 
36
+ ngx_feature="epoll"
37
+ ngx_feature_name="NGX_HAVE_EPOLL"
38
+-ngx_feature_run=yes
39
++ngx_feature_run=no
40
+ ngx_feature_incs="#include <sys/epoll.h>"
41
+ ngx_feature_path=
42
+ ngx_feature_libs=
43
+@@ -73,7 +73,7 @@ fi
44
+ CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE"
45
+ ngx_feature="sendfile()"
46
+ ngx_feature_name="NGX_HAVE_SENDFILE"
47
+-ngx_feature_run=yes
48
++ngx_feature_run=no
49
+ ngx_feature_incs="#include <sys/sendfile.h>
50
+                   #include <errno.h>"
51
+ ngx_feature_path=
52
+@@ -94,7 +94,7 @@ fi
53
+ CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
54
+ ngx_feature="sendfile64()"
55
+ ngx_feature_name="NGX_HAVE_SENDFILE64"
56
+-ngx_feature_run=yes
57
++ngx_feature_run=no
58
+ ngx_feature_incs="#include <sys/sendfile.h>
59
+                   #include <errno.h>"
60
+ ngx_feature_path=
61
+@@ -112,7 +112,7 @@ ngx_include="sys/prctl.h"; . auto/includ
62
+ 
63
+ ngx_feature="prctl(PR_SET_DUMPABLE)"
64
+ ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE"
65
+-ngx_feature_run=yes
66
++ngx_feature_run=no
67
+ ngx_feature_incs="#include <sys/prctl.h>"
68
+ ngx_feature_path=
69
+ ngx_feature_libs=
70
+--- a/auto/unix
71
++++ b/auto/unix
72
+@@ -618,7 +618,7 @@ ngx_feature_test="void *p; p = memalign(
73
+ 
74
+ ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
75
+ ngx_feature_name="NGX_HAVE_MAP_ANON"
76
+-ngx_feature_run=yes
77
++ngx_feature_run=no
78
+ ngx_feature_incs="#include <sys/mman.h>"
79
+ ngx_feature_path=
80
+ ngx_feature_libs=
81
+@@ -631,7 +631,7 @@ ngx_feature_test="void *p;
82
+ 
83
+ ngx_feature='mmap("/dev/zero", MAP_SHARED)'
84
+ ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
85
+-ngx_feature_run=yes
86
++ngx_feature_run=no
87
+ ngx_feature_incs="#include <sys/mman.h>
88
+                   #include <sys/stat.h>
89
+                   #include <fcntl.h>"
90
+@@ -646,7 +646,7 @@ ngx_feature_test='void *p; int  fd;
91
+ 
92
+ ngx_feature="System V shared memory"
93
+ ngx_feature_name="NGX_HAVE_SYSVSHM"
94
+-ngx_feature_run=yes
95
++ngx_feature_run=no
96
+ ngx_feature_incs="#include <sys/ipc.h>
97
+                   #include <sys/shm.h>"
98
+ ngx_feature_path=
99
+@@ -660,7 +660,7 @@ ngx_feature_test="int  id;
100
+ 
101
+ ngx_feature="POSIX semaphores"
102
+ ngx_feature_name="NGX_HAVE_POSIX_SEM"
103
+-ngx_feature_run=yes
104
++ngx_feature_run=no
105
+ ngx_feature_incs="#include <semaphore.h>"
106
+ ngx_feature_path=
107
+ ngx_feature_libs=

+ 26
- 0
net/nginx/patches/102-sizeof_test_fix.patch View File

@@ -0,0 +1,26 @@
1
+--- a/auto/types/sizeof
2
++++ b/auto/types/sizeof
3
+@@ -25,8 +25,13 @@ $NGX_INCLUDE_UNISTD_H
4
+ $NGX_INCLUDE_INTTYPES_H
5
+ $NGX_INCLUDE_AUTO_CONFIG_H
6
+ 
7
++char object_code_block[] = {
8
++	'\n', 'e', '4', 'V', 'A',
9
++	'0', 'x', ('0' + sizeof($ngx_type)),
10
++	'Y', '3', 'p', 'M', '\n'
11
++};
12
++
13
+ int main() {
14
+-    printf("%d", (int) sizeof($ngx_type));
15
+     return 0;
16
+ }
17
+ 
18
+@@ -40,7 +45,7 @@ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&
19
+ 
20
+ 
21
+ if [ -x $NGX_AUTOTEST ]; then
22
+-    ngx_size=`$NGX_AUTOTEST`
23
++    ngx_size=`sed -ne 's/^e4VA0x\(.\)Y3pM$/\1/p' < $NGX_AUTOTEST`
24
+     echo " $ngx_size bytes"
25
+ fi
26
+ 

+ 12
- 0
net/nginx/patches/103-sys_nerr.patch View File

@@ -0,0 +1,12 @@
1
+--- a/src/os/unix/ngx_errno.c
2
++++ b/src/os/unix/ngx_errno.c
3
+@@ -8,6 +8,9 @@
4
+ #include <ngx_config.h>
5
+ #include <ngx_core.h>
6
+ 
7
++#ifndef NGX_SYS_NERR
8
++#define NGX_SYS_NERR  128
9
++#endif
10
+ 
11
+ /*
12
+  * The strerror() messages are copied because:

+ 18
- 0
net/nginx/patches/200-config.patch View File

@@ -0,0 +1,18 @@
1
+--- a/conf/nginx.conf
2
++++ b/conf/nginx.conf
3
+@@ -1,5 +1,5 @@
4
+ 
5
+-#user  nobody;
6
++user nobody nogroup;
7
+ worker_processes  1;
8
+ 
9
+ #error_log  logs/error.log;
10
+@@ -16,7 +16,7 @@ events {
11
+ 
12
+ http {
13
+     include       mime.types;
14
+-    default_type  application/octet-stream;
15
++    #default_type  application/octet-stream;
16
+ 
17
+     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
18
+     #                  '$status $body_bytes_sent "$http_referer" '

+ 33
- 0
net/nginx/patches/300-crosscompile_ccflags.patch View File

@@ -0,0 +1,33 @@
1
+--- a/auto/endianness
2
++++ b/auto/endianness
3
+@@ -21,7 +21,7 @@ int main() {
4
+ 
5
+ END
6
+ 
7
+-ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
8
++ngx_test="$CC $NGX_CC_OPT $CC_TEST_FLAGS $CC_AUX_FLAGS \
9
+           -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
10
+ 
11
+ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
12
+--- a/auto/feature
13
++++ b/auto/feature
14
+@@ -39,7 +39,7 @@ int main() {
15
+ END
16
+ 
17
+ 
18
+-ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS $ngx_feature_inc_path \
19
++ngx_test="$CC $NGX_CC_OPT $CC_TEST_FLAGS $CC_AUX_FLAGS $ngx_feature_inc_path \
20
+           -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_TEST_LD_OPT $ngx_feature_libs"
21
+ 
22
+ ngx_feature_inc_path=
23
+--- a/auto/include
24
++++ b/auto/include
25
+@@ -27,7 +27,7 @@ int main() {
26
+ END
27
+ 
28
+ 
29
+-ngx_test="$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
30
++ngx_test="$CC $NGX_CC_OPT -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
31
+ 
32
+ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
33
+ 

+ 1194
- 0
net/nginx/patches/400-nginx-1.4.x_proxy_protocol_patch_v2.patch
File diff suppressed because it is too large
View File


+ 698
- 0
net/nginx/patches/401-nginx-1.4.0-syslog.patch View File

@@ -0,0 +1,698 @@
1
+Index: nginx-1.4.7/src/core/ngx_cycle.c
2
+===================================================================
3
+--- nginx-1.4.7.orig/src/core/ngx_cycle.c
4
++++ nginx-1.4.7/src/core/ngx_cycle.c
5
+@@ -85,6 +85,12 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
6
+     cycle->pool = pool;
7
+     cycle->log = log;
8
+     cycle->new_log.log_level = NGX_LOG_ERR;
9
++#if (NGX_ENABLE_SYSLOG)
10
++    cycle->new_log.facility = SYSLOG_FACILITY;
11
++    cycle->new_log.facility = ERR_SYSLOG_PRIORITY;
12
++    cycle->new_log.syslog_on = 0;
13
++    cycle->new_log.syslog_set = 0;
14
++#endif
15
+     cycle->old_cycle = old_cycle;
16
+ 
17
+     cycle->conf_prefix.len = old_cycle->conf_prefix.len;
18
+Index: nginx-1.4.7/src/core/ngx_log.c
19
+===================================================================
20
+--- nginx-1.4.7.orig/src/core/ngx_log.c
21
++++ nginx-1.4.7/src/core/ngx_log.c
22
+@@ -10,6 +10,15 @@
23
+ 
24
+ 
25
+ static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
26
++#if (NGX_ENABLE_SYSLOG)
27
++static char *ngx_set_syslog(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
28
++void log_exit(ngx_cycle_t *cycle);
29
++
30
++typedef struct{
31
++    ngx_str_t     name;
32
++    ngx_int_t     macro;
33
++} ngx_string_to_macro_t;
34
++#endif
35
+ 
36
+ 
37
+ static ngx_command_t  ngx_errlog_commands[] = {
38
+@@ -21,6 +30,15 @@ static ngx_command_t  ngx_errlog_command
39
+      0,
40
+      NULL},
41
+ 
42
++#if (NGX_ENABLE_SYSLOG)
43
++    {ngx_string("syslog"),
44
++     NGX_MAIN_CONF|NGX_CONF_TAKE12,
45
++     ngx_set_syslog,
46
++     0,
47
++     0,
48
++     NULL},
49
++#endif
50
++
51
+     ngx_null_command
52
+ };
53
+ 
54
+@@ -43,7 +61,11 @@ ngx_module_t  ngx_errlog_module = {
55
+     NULL,                                  /* init thread */
56
+     NULL,                                  /* exit thread */
57
+     NULL,                                  /* exit process */
58
+-    NULL,                                  /* exit master */
59
++#if (NGX_ENABLE_SYSLOG)
60
++    log_exit,                              /* exit master */
61
++#else
62
++    NULL,
63
++#endif
64
+     NGX_MODULE_V1_PADDING
65
+ };
66
+ 
67
+@@ -52,6 +74,48 @@ static ngx_log_t        ngx_log;
68
+ static ngx_open_file_t  ngx_log_file;
69
+ ngx_uint_t              ngx_use_stderr = 1;
70
+ 
71
++#if (NGX_ENABLE_SYSLOG)
72
++static ngx_string_to_macro_t ngx_syslog_facilities[] = {
73
++    {ngx_string("auth"),     LOG_AUTH},
74
++#if !(NGX_SOLARIS)
75
++    {ngx_string("authpriv"), LOG_AUTHPRIV},
76
++#endif
77
++    {ngx_string("cron"),     LOG_CRON},
78
++    {ngx_string("daemon"),   LOG_DAEMON},
79
++#if !(NGX_SOLARIS)
80
++    {ngx_string("ftp"),      LOG_FTP},
81
++#endif
82
++    {ngx_string("kern"),     LOG_KERN},
83
++    {ngx_string("local0"),   LOG_LOCAL0},
84
++    {ngx_string("local1"),   LOG_LOCAL1},
85
++    {ngx_string("local2"),   LOG_LOCAL2},
86
++    {ngx_string("local3"),   LOG_LOCAL3},
87
++    {ngx_string("local4"),   LOG_LOCAL4},
88
++    {ngx_string("local5"),   LOG_LOCAL5},
89
++    {ngx_string("local6"),   LOG_LOCAL6},
90
++    {ngx_string("local7"),   LOG_LOCAL7},
91
++    {ngx_string("lpr"),      LOG_LPR},
92
++    {ngx_string("mail"),     LOG_MAIL},
93
++    {ngx_string("news"),     LOG_NEWS},
94
++    {ngx_string("syslog"),   LOG_SYSLOG},
95
++    {ngx_string("user"),     LOG_USER},
96
++    {ngx_string("uucp"),     LOG_UUCP},
97
++    { ngx_null_string, 0}
98
++};
99
++
100
++static ngx_string_to_macro_t ngx_syslog_priorities[] = {
101
++    {ngx_string("emerg"), LOG_EMERG},
102
++    {ngx_string("alert"), LOG_ALERT},
103
++    {ngx_string("crit"),  LOG_CRIT},
104
++    {ngx_string("error"), LOG_ERR},
105
++    {ngx_string("err"),   LOG_ERR},
106
++    {ngx_string("warn"),  LOG_WARNING},
107
++    {ngx_string("notice"),LOG_NOTICE},
108
++    {ngx_string("info"),  LOG_INFO},
109
++    {ngx_string("debug"), LOG_DEBUG},
110
++    { ngx_null_string, 0}
111
++};
112
++#endif
113
+ 
114
+ static ngx_str_t err_levels[] = {
115
+     ngx_null_string,
116
+@@ -89,11 +153,16 @@ ngx_log_error_core(ngx_uint_t level, ngx
117
+     va_list  args;
118
+ #endif
119
+     u_char  *p, *last, *msg;
120
++#if (NGX_ENABLE_SYSLOG)
121
++    u_char *errstr_syslog;
122
++#endif
123
+     u_char   errstr[NGX_MAX_ERROR_STR];
124
+ 
125
++#if !(NGX_ENABLE_SYSLOG)
126
+     if (log->file->fd == NGX_INVALID_FILE) {
127
+         return;
128
+     }
129
++#endif
130
+ 
131
+     last = errstr + NGX_MAX_ERROR_STR;
132
+ 
133
+@@ -102,6 +171,10 @@ ngx_log_error_core(ngx_uint_t level, ngx
134
+ 
135
+     p = errstr + ngx_cached_err_log_time.len;
136
+ 
137
++#if (NGX_ENABLE_SYSLOG)
138
++    errstr_syslog = p;
139
++#endif
140
++
141
+     p = ngx_slprintf(p, last, " [%V] ", &err_levels[level]);
142
+ 
143
+     /* pid#tid */
144
+@@ -140,11 +213,27 @@ ngx_log_error_core(ngx_uint_t level, ngx
145
+ 
146
+     ngx_linefeed(p);
147
+ 
148
++#if (NGX_ENABLE_SYSLOG)
149
++    if (log->file != NULL && log->file->name.len != 0) {
150
+     (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
151
++    }
152
++
153
++    /* Don't send the debug level info to syslog */
154
++    if (log->syslog_on && level < NGX_LOG_DEBUG) {
155
++        /* write to syslog */
156
++        syslog(log->priority, "%.*s", (int)(p - errstr_syslog), errstr_syslog);
157
++    }
158
++#else
159
++    (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
160
++#endif
161
+ 
162
+     if (!ngx_use_stderr
163
+         || level > NGX_LOG_WARN
164
++#if (NGX_ENABLE_SYSLOG)
165
++        || (log->file != NULL && log->file->fd == ngx_stderr))
166
++#else
167
+         || log->file->fd == ngx_stderr)
168
++#endif
169
+     {
170
+         return;
171
+     }
172
+@@ -367,6 +456,50 @@ ngx_log_create(ngx_cycle_t *cycle, ngx_s
173
+ }
174
+ 
175
+ 
176
++#if (NGX_ENABLE_SYSLOG)
177
++ngx_int_t
178
++ngx_log_get_priority(ngx_conf_t *cf, ngx_str_t *priority)
179
++{
180
++    ngx_int_t  p = 0;
181
++    ngx_uint_t n, match = 0;
182
++
183
++    for (n = 0; ngx_syslog_priorities[n].name.len != 0; n++) {
184
++        if (ngx_strncmp(priority->data, ngx_syslog_priorities[n].name.data, 
185
++                    ngx_syslog_priorities[n].name.len) == 0) {
186
++            p = ngx_syslog_priorities[n].macro;
187
++            match = 1;
188
++        }
189
++    }
190
++
191
++    if (!match) {
192
++        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
193
++                "invalid syslog priority \"%V\"", priority);
194
++        return -1;
195
++    }
196
++
197
++    return p;
198
++}
199
++
200
++
201
++char *
202
++ngx_log_set_priority(ngx_conf_t *cf, ngx_str_t *priority, ngx_log_t *log)
203
++{
204
++    log->priority = ERR_SYSLOG_PRIORITY;
205
++
206
++    if (priority->len == 0) {
207
++        return NGX_CONF_OK;
208
++    }
209
++
210
++    log->priority = ngx_log_get_priority(cf, priority);
211
++    if (log->priority == (-1)) {
212
++        return NGX_CONF_ERROR;
213
++    }
214
++
215
++    return NGX_CONF_OK;
216
++}
217
++#endif
218
++
219
++
220
+ char *
221
+ ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
222
+ {
223
+@@ -429,6 +562,13 @@ static char *
224
+ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
225
+ {
226
+     ngx_str_t  *value, name;
227
++#if (NGX_ENABLE_SYSLOG)
228
++    u_char     *off = NULL;
229
++    ngx_str_t  priority;
230
++
231
++    ngx_str_null(&name);
232
++    ngx_str_null(&priority);
233
++#endif
234
+ 
235
+     if (cf->cycle->new_log.file) {
236
+         return "is duplicate";
237
+@@ -436,7 +576,44 @@ ngx_error_log(ngx_conf_t *cf, ngx_comman
238
+ 
239
+     value = cf->args->elts;
240
+ 
241
++#if (NGX_ENABLE_SYSLOG)
242
++    if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
243
++        if (!cf->cycle->new_log.syslog_set) {
244
++            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
245
++                    "You must set the syslog directive and enable it first.");
246
++            return NGX_CONF_ERROR;
247
++        }
248
++
249
++        cf->cycle->new_log.syslog_on = 1;
250
++
251
++        if (value[1].data[sizeof("syslog") - 1] == ':') {
252
++            priority.len = value[1].len - sizeof("syslog");
253
++            priority.data = value[1].data + sizeof("syslog");
254
++
255
++            off = (u_char *)ngx_strchr(priority.data, (int) '|');
256
++            if (off != NULL) {
257
++                priority.len = off - priority.data;
258
++
259
++                off++;
260
++                name.len = value[1].data + value[1].len - off;
261
++                name.data = off;
262
++            }
263
++        }
264
++        else {
265
++            if (value[1].len > sizeof("syslog")) {
266
++                name.len = value[1].len - sizeof("syslog");
267
++                name.data = value[1].data + sizeof("syslog");
268
++            }
269
++        }
270
++
271
++        if (ngx_log_set_priority(cf, &priority, &cf->cycle->new_log) == NGX_CONF_ERROR) {
272
++            return NGX_CONF_ERROR;
273
++        }
274
++    }
275
++    else if (ngx_strcmp(value[1].data, "stderr") == 0) {
276
++#else
277
+     if (ngx_strcmp(value[1].data, "stderr") == 0) {
278
++#endif
279
+         ngx_str_null(&name);
280
+ 
281
+     } else {
282
+@@ -457,3 +634,63 @@ ngx_error_log(ngx_conf_t *cf, ngx_comman
283
+ 
284
+     return ngx_log_set_levels(cf, &cf->cycle->new_log);
285
+ }
286
++
287
++
288
++#if (NGX_ENABLE_SYSLOG)
289
++
290
++#define SYSLOG_IDENT_NAME "nginx"
291
++
292
++static char *
293
++ngx_set_syslog(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
294
++{
295
++    char       *program;
296
++    ngx_str_t  *value;
297
++    ngx_int_t   facility, match = 0;
298
++    ngx_uint_t  n;
299
++
300
++    value = cf->args->elts;
301
++
302
++    if (cf->cycle->new_log.syslog_set) {
303
++        return "is duplicate";
304
++    }
305
++
306
++    cf->cycle->new_log.syslog_set = 1;
307
++
308
++    for (n = 0; ngx_syslog_facilities[n].name.len != 0; n++) {
309
++        if (ngx_strncmp(value[1].data, ngx_syslog_facilities[n].name.data, 
310
++                    ngx_syslog_facilities[n].name.len) == 0) {
311
++            facility = ngx_syslog_facilities[n].macro;
312
++            match = 1;
313
++            break;
314
++        }
315
++    }
316
++
317
++    if (match) {
318
++        cf->cycle->new_log.facility = facility;
319
++        cf->cycle->new_log.priority = ERR_SYSLOG_PRIORITY;
320
++    }
321
++    else {
322
++        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
323
++                "invalid syslog facility \"%V\"", &value[1]);
324
++        return NGX_CONF_ERROR;
325
++    }
326
++
327
++    program = SYSLOG_IDENT_NAME; 
328
++    if (cf->args->nelts > 2) {
329
++        program = (char *) value[2].data;
330
++    }
331
++
332
++    openlog(program, LOG_ODELAY, facility);
333
++
334
++    return NGX_CONF_OK;
335
++}
336
++
337
++
338
++void log_exit(ngx_cycle_t *cycle)
339
++{
340
++    if (cycle->new_log.syslog_set) {
341
++        closelog();
342
++    }
343
++}
344
++#endif
345
++
346
+Index: nginx-1.4.7/src/core/ngx_log.h
347
+===================================================================
348
+--- nginx-1.4.7.orig/src/core/ngx_log.h
349
++++ nginx-1.4.7/src/core/ngx_log.h
350
+@@ -12,6 +12,13 @@
351
+ #include <ngx_config.h>
352
+ #include <ngx_core.h>
353
+ 
354
++#if (NGX_ENABLE_SYSLOG)
355
++#include <syslog.h>
356
++
357
++#define SYSLOG_FACILITY LOG_LOCAL5
358
++#define ERR_SYSLOG_PRIORITY LOG_ERR
359
++#endif
360
++
361
+ 
362
+ #define NGX_LOG_STDERR            0
363
+ #define NGX_LOG_EMERG             1
364
+@@ -61,6 +68,13 @@ struct ngx_log_s {
365
+      */
366
+ 
367
+     char                *action;
368
++
369
++#if (NGX_ENABLE_SYSLOG)
370
++    ngx_int_t           priority;
371
++    ngx_int_t           facility;
372
++    unsigned            syslog_on:1;      /* unsigned :1 syslog_on */
373
++    unsigned            syslog_set:1;      /*unsigned :1 syslog_set */
374
++#endif
375
+ };
376
+ 
377
+ 
378
+@@ -221,6 +235,10 @@ void ngx_cdecl ngx_log_debug_core(ngx_lo
379
+ 
380
+ ngx_log_t *ngx_log_init(u_char *prefix);
381
+ ngx_log_t *ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name);
382
++#if (NGX_ENABLE_SYSLOG)
383
++ngx_int_t ngx_log_get_priority(ngx_conf_t *cf, ngx_str_t *priority);
384
++char * ngx_log_set_priority(ngx_conf_t *cf, ngx_str_t *priority, ngx_log_t *log);
385
++#endif
386
+ char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
387
+ void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);
388
+ void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
389
+Index: nginx-1.4.7/src/http/modules/ngx_http_log_module.c
390
+===================================================================
391
+--- nginx-1.4.7.orig/src/http/modules/ngx_http_log_module.c
392
++++ nginx-1.4.7/src/http/modules/ngx_http_log_module.c
393
+@@ -13,6 +13,11 @@
394
+ #include <zlib.h>
395
+ #endif
396
+ 
397
++#if (NGX_ENABLE_SYSLOG)
398
++#include <syslog.h>
399
++
400
++#define HTTP_SYSLOG_PRIORITY LOG_NOTICE
401
++#endif
402
+ 
403
+ typedef struct ngx_http_log_op_s  ngx_http_log_op_t;
404
+ 
405
+@@ -67,6 +72,11 @@ typedef struct {
406
+     time_t                      disk_full_time;
407
+     time_t                      error_log_time;
408
+     ngx_http_log_fmt_t         *format;
409
++
410
++#if (NGX_ENABLE_SYSLOG)
411
++    ngx_int_t                   priority;
412
++    unsigned                    syslog_on:1;      /* unsigned :1 syslog_on */
413
++#endif
414
+ } ngx_http_log_t;
415
+ 
416
+ 
417
+@@ -348,6 +358,14 @@ ngx_http_log_write(ngx_http_request_t *r
418
+     time_t               now;
419
+     ssize_t              n;
420
+     ngx_err_t            err;
421
++
422
++#if (NGX_ENABLE_SYSLOG)
423
++    n = 0;
424
++    if (log->syslog_on) {
425
++        syslog(log->priority, "%.*s", (int)len, buf);
426
++    }
427
++#endif
428
++
429
+ #if (NGX_ZLIB)
430
+     ngx_http_log_buf_t  *buffer;
431
+ #endif
432
+@@ -355,6 +373,9 @@ ngx_http_log_write(ngx_http_request_t *r
433
+     if (log->script == NULL) {
434
+         name = log->file->name.data;
435
+ 
436
++#if (NGX_ENABLE_SYSLOG)
437
++        if (name != NULL) {
438
++#endif
439
+ #if (NGX_ZLIB)
440
+         buffer = log->file->data;
441
+ 
442
+@@ -367,7 +388,11 @@ ngx_http_log_write(ngx_http_request_t *r
443
+ #else
444
+         n = ngx_write_fd(log->file->fd, buf, len);
445
+ #endif
446
+-
447
++#if (NGX_ENABLE_SYSLOG)
448
++        } else {
449
++            n = len;
450
++        }
451
++#endif
452
+     } else {
453
+         name = NULL;
454
+         n = ngx_http_log_script_write(r, log->script, &name, buf, len);
455
+@@ -1068,6 +1093,10 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *
456
+     log->script = NULL;
457
+     log->disk_full_time = 0;
458
+     log->error_log_time = 0;
459
++#if (NGX_ENABLE_SYSLOG)
460
++    log->priority = HTTP_SYSLOG_PRIORITY;
461
++    log->syslog_on = 0;
462
++#endif
463
+ 
464
+     lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
465
+     fmt = lmcf->formats.elts;
466
+@@ -1096,6 +1125,13 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
467
+     ngx_http_log_main_conf_t   *lmcf;
468
+     ngx_http_script_compile_t   sc;
469
+ 
470
++#if (NGX_ENABLE_SYSLOG)
471
++    u_char                     *off;
472
++    ngx_str_t                   priority;
473
++    ngx_uint_t                  syslog_on = 0;
474
++    name = priority = (ngx_str_t)ngx_null_string;
475
++#endif
476
++
477
+     value = cf->args->elts;
478
+ 
479
+     if (ngx_strcmp(value[1].data, "off") == 0) {
480
+@@ -1108,6 +1144,38 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
481
+                            "invalid parameter \"%V\"", &value[2]);
482
+         return NGX_CONF_ERROR;
483
+     }
484
++#if (NGX_ENABLE_SYSLOG)
485
++    else if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
486
++        if (!cf->cycle->new_log.syslog_set) {
487
++            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
488
++                               "You must set the syslog directive and enable it first.");
489
++            return NGX_CONF_ERROR;
490
++        }
491
++
492
++        syslog_on = 1;
493
++        if (value[1].data[sizeof("syslog") - 1] == ':') {
494
++            priority.len = value[1].len - sizeof("syslog");
495
++            priority.data = value[1].data + sizeof("syslog");
496
++
497
++            off = (u_char*) ngx_strchr(priority.data, '|'); 
498
++            if (off != NULL) {
499
++                priority.len = off - priority.data;
500
++                
501
++                off++;
502
++                name.len = value[1].data + value[1].len - off;
503
++                name.data = off;
504
++            }
505
++        }
506
++        else {
507
++            if (value[1].len > sizeof("syslog")) {
508
++                name.len = value[1].len - sizeof("syslog");
509
++                name.data = value[1].data + sizeof("syslog");
510
++            }
511
++        }
512
++    } else {
513
++        name = value[1];
514
++    }
515
++#endif
516
+ 
517
+     if (llcf->logs == NULL) {
518
+         llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
519
+@@ -1125,6 +1193,52 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
520
+ 
521
+     ngx_memzero(log, sizeof(ngx_http_log_t));
522
+ 
523
++#if (NGX_ENABLE_SYSLOG)
524
++    log->syslog_on = syslog_on;
525
++
526
++    if (priority.len == 0) {
527
++        log->priority = HTTP_SYSLOG_PRIORITY;
528
++    }
529
++    else {
530
++        log->priority = ngx_log_get_priority(cf, &priority);
531
++    }
532
++
533
++    if (name.len != 0) {
534
++        n = ngx_http_script_variables_count(&name);
535
++
536
++        if (n == 0) {
537
++            log->file = ngx_conf_open_file(cf->cycle, &name);
538
++            if (log->file == NULL) {
539
++                return NGX_CONF_ERROR;
540
++            }
541
++        } else {
542
++            if (ngx_conf_full_name(cf->cycle, &name, 0) != NGX_OK) {
543
++                return NGX_CONF_ERROR;
544
++            }
545
++            log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
546
++            if (log->script == NULL) {
547
++                return NGX_CONF_ERROR;
548
++            }
549
++            ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
550
++            sc.cf = cf;
551
++            sc.source = &name;
552
++            sc.lengths = &log->script->lengths;
553
++            sc.values = &log->script->values;
554
++            sc.variables = n;
555
++            sc.complete_lengths = 1;
556
++            sc.complete_values = 1;
557
++            if (ngx_http_script_compile(&sc) != NGX_OK) {
558
++                return NGX_CONF_ERROR;
559
++            }
560
++        }
561
++    }
562
++    else {
563
++        log->file = ngx_conf_open_file(cf->cycle, &name);
564
++        if (log->file == NULL) {
565
++            return NGX_CONF_ERROR;
566
++        }
567
++    }
568
++#else
569
+     n = ngx_http_script_variables_count(&value[1]);
570
+ 
571
+     if (n == 0) {
572
+@@ -1157,6 +1271,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
573
+             return NGX_CONF_ERROR;
574
+         }
575
+     }
576
++#endif
577
+ 
578
+     if (cf->args->nelts >= 3) {
579
+         name = value[2];
580
+Index: nginx-1.4.7/src/http/ngx_http_core_module.c
581
+===================================================================
582
+--- nginx-1.4.7.orig/src/http/ngx_http_core_module.c
583
++++ nginx-1.4.7/src/http/ngx_http_core_module.c
584
+@@ -1462,6 +1462,9 @@ ngx_http_update_location_config(ngx_http
585
+ 
586
+     if (r == r->main) {
587
+         ngx_http_set_connection_log(r->connection, clcf->error_log);
588
++#if (NGX_ENABLE_SYSLOG)
589
++        r->connection->log->priority = clcf->error_log->priority;
590
++#endif
591
+     }
592
+ 
593
+     if ((ngx_io.flags & NGX_IO_SENDFILE) && clcf->sendfile) {
594
+@@ -4901,6 +4904,15 @@ ngx_http_core_error_log(ngx_conf_t *cf,
595
+ 
596
+     ngx_str_t  *value, name;
597
+ 
598
++#if (NGX_ENABLE_SYSLOG)
599
++    u_char     *off = NULL;
600
++    ngx_int_t   syslog_on = 0;
601
++    ngx_str_t   priority;
602
++
603
++    name = priority = (ngx_str_t) ngx_null_string;
604
++#endif
605
++
606
++
607
+     if (clcf->error_log) {
608
+         return "is duplicate";
609
+     }
610
+@@ -4910,6 +4922,36 @@ ngx_http_core_error_log(ngx_conf_t *cf,
611
+     if (ngx_strcmp(value[1].data, "stderr") == 0) {
612
+         ngx_str_null(&name);
613
+ 
614
++#if (NGX_ENABLE_SYSLOG)
615
++    } else if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
616
++        if (!cf->cycle->new_log.syslog_set) {
617
++            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
618
++                    "You must set the syslog directive and enable it first.");
619
++            return NGX_CONF_ERROR;
620
++        }
621
++
622
++        syslog_on = 1;
623
++
624
++        if (value[1].data[sizeof("syslog") - 1] == ':') {
625
++            priority.len = value[1].len - sizeof("syslog");
626
++            priority.data = value[1].data + sizeof("syslog");
627
++
628
++            off = (u_char*) ngx_strchr(priority.data, '|'); 
629
++            if (off != NULL) {
630
++                priority.len = off - priority.data;
631
++
632
++                off++;
633
++                name.len = value[1].data + value[1].len - off;
634
++                name.data = off;
635
++            }
636
++        }
637
++        else {
638
++            if (value[1].len > sizeof("syslog")) {
639
++                name.len = value[1].len - sizeof("syslog");
640
++                name.data = value[1].data + sizeof("syslog");
641
++            }
642
++        }
643
++#endif
644
+     } else {
645
+         name = value[1];
646
+     }
647
+@@ -4919,6 +4961,17 @@ ngx_http_core_error_log(ngx_conf_t *cf,
648
+         return NGX_CONF_ERROR;
649
+     }
650
+ 
651
++#if (NGX_ENABLE_SYSLOG)
652
++    if (syslog_on) {
653
++        clcf->error_log->syslog_on = 1;
654
++        if (ngx_log_set_priority(cf, &priority, clcf->error_log) == NGX_CONF_ERROR) {
655
++            return NGX_CONF_ERROR;
656
++        }
657
++    }
658
++
659
++    clcf->error_log->log_level = 0;
660
++#endif
661
++
662
+     if (cf->args->nelts == 2) {
663
+         clcf->error_log->log_level = NGX_LOG_ERR;
664
+         return NGX_CONF_OK;
665
+Index: nginx-1.4.7/src/http/ngx_http_request.c
666
+===================================================================
667
+--- nginx-1.4.7.orig/src/http/ngx_http_request.c
668
++++ nginx-1.4.7/src/http/ngx_http_request.c
669
+@@ -533,6 +533,9 @@ ngx_http_create_request(ngx_connection_t
670
+     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
671
+ 
672
+     ngx_http_set_connection_log(r->connection, clcf->error_log);
673
++#if (NGX_ENABLE_SYSLOG)
674
++    c->log->priority = clcf->error_log->priority;
675
++#endif
676
+ 
677
+     r->header_in = hc->nbusy ? hc->busy[0] : c->buffer;
678
+ 
679
+@@ -872,6 +875,9 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *
680
+     clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
681
+ 
682
+     ngx_http_set_connection_log(c, clcf->error_log);
683
++#if (NGX_ENABLE_SYSLOG)
684
++    c->log->priority = clcf->error_log->priority;
685
++#endif
686
+ 
687
+     sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module);
688
+ 
689
+@@ -2077,6 +2083,9 @@ ngx_http_set_virtual_server(ngx_http_req
690
+     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
691
+ 
692
+     ngx_http_set_connection_log(r->connection, clcf->error_log);
693
++#if (NGX_ENABLE_SYSLOG)
694
++    r->connection->log->priority = clcf->error_log->priority;
695
++#endif
696
+ 
697
+     return NGX_OK;
698
+ }