Merge pull request #48 from heil/master
nginx: import from packages, add myself as the maintainer
This commit is contained in:
commit
3251ba625d
14 changed files with 2962 additions and 0 deletions
187
net/nginx/Config.in
Normal file
187
net/nginx/Config.in
Normal file
|
@ -0,0 +1,187 @@
|
|||
#
|
||||
# Copyright (C) 2010-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
menu "Configuration"
|
||||
depends on PACKAGE_nginx
|
||||
|
||||
config NGINX_STUB_STATUS
|
||||
bool
|
||||
prompt "Enable stub status module"
|
||||
help
|
||||
Enable the stub status module which gives some status from the server.
|
||||
|
||||
config NGINX_FLV
|
||||
bool
|
||||
prompt "Enable FLV module"
|
||||
help
|
||||
Provides the ability to seek within FLV (Flash) files using time-based offsets.
|
||||
|
||||
config NGINX_SSL
|
||||
bool
|
||||
prompt "Enable SSL module"
|
||||
help
|
||||
Enable HTTPS/SSL support.
|
||||
|
||||
config NGINX_DAV
|
||||
bool
|
||||
prompt "Enable WebDAV module"
|
||||
help
|
||||
Enable the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and MOVE.
|
||||
|
||||
config NGINX_LUA
|
||||
bool
|
||||
prompt "Enable LUA module"
|
||||
help
|
||||
Enable support for LUA scripts.
|
||||
|
||||
config NGINX_PCRE
|
||||
bool
|
||||
prompt "Enable PCRE library usage"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_CACHE
|
||||
bool
|
||||
prompt "Enable HTTP cache"
|
||||
|
||||
config NGINX_HTTP_CHARSET
|
||||
bool
|
||||
prompt "Enable HTTP charset module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_GZIP
|
||||
bool
|
||||
prompt "Enable HTTP gzip module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_SSI
|
||||
bool
|
||||
prompt "Enable HTTP ssi module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_USERID
|
||||
bool
|
||||
prompt "Enable HTTP userid module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_ACCESS
|
||||
bool
|
||||
prompt "Enable HTTP access module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_AUTH_BASIC
|
||||
bool
|
||||
prompt "Enable HTTP auth basic"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_AUTOINDEX
|
||||
bool
|
||||
prompt "Enable HTTP autoindex module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_GEO
|
||||
bool
|
||||
prompt "Enable HTTP geo module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_MAP
|
||||
bool
|
||||
prompt "Enable HTTP map module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_SPLIT_CLIENTS
|
||||
bool
|
||||
prompt "Enable HTTP split clients"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_REFERER
|
||||
bool
|
||||
prompt "Enable HTTP referer module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_REWRITE
|
||||
bool
|
||||
prompt "Enable HTTP rewrite module"
|
||||
select NGINX_PCRE
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_PROXY
|
||||
bool
|
||||
prompt "Enable HTTP proxy module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_FASTCGI
|
||||
bool
|
||||
prompt "Enable HTTP fastcgi module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_UWSGI
|
||||
bool
|
||||
prompt "Enable HTTP uwsgi module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_SCGI
|
||||
bool
|
||||
prompt "Enable HTTP scgi module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_MEMCACHED
|
||||
bool
|
||||
prompt "Enable HTTP memcached module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_LIMIT_CONN
|
||||
bool
|
||||
prompt "Enable HTTP limit conn"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_LIMIT_REQ
|
||||
bool
|
||||
prompt "Enable HTTP limit req"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_EMPTY_GIF
|
||||
bool
|
||||
prompt "Enable HTTP empty gif"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_BROWSER
|
||||
bool
|
||||
prompt "Enable HTTP browser module"
|
||||
default y
|
||||
|
||||
config NGINX_HTTP_UPSTREAM_IP_HASH
|
||||
bool
|
||||
prompt "Enable HTTP IP hash module"
|
||||
default y
|
||||
|
||||
config NGINX_NAXSI
|
||||
bool
|
||||
prompt "Enable NAXSI module"
|
||||
select PACKAGE_nginx-naxsi
|
||||
help
|
||||
Enable support for NAXSI WAF.
|
||||
|
||||
config NGINX_PROXYPROTOCOL
|
||||
bool
|
||||
prompt "Enable NAXSI proxyprotocol"
|
||||
select PACKAGE_nginx-proxyprotocol
|
||||
help
|
||||
Enable support for NAXSI WAF.
|
||||
|
||||
config NGINX_SYSLOG
|
||||
bool
|
||||
prompt "Enable Syslog module"
|
||||
select PACKAGE_nginx-syslog
|
||||
help
|
||||
Provides the ability log to a remote destination
|
||||
|
||||
config NGINX_HTTP_UPSTREAM_CHECK
|
||||
bool
|
||||
prompt "Enable HTTP upstream check module"
|
||||
default y
|
||||
|
||||
endmenu
|
334
net/nginx/Makefile
Normal file
334
net/nginx/Makefile
Normal file
|
@ -0,0 +1,334 @@
|
|||
#
|
||||
# Copyright (C) 2009-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=nginx
|
||||
PKG_VERSION:=1.4.7
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://nginx.org/download/
|
||||
PKG_MD5SUM:=aee151d298dcbfeb88b3f7dd3e7a4d17
|
||||
PKG_MAINTAINER:=Thomas Heil <heil@terminal-consulting.de>
|
||||
PKG_LICENSE:=2-clause BSD-like license
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
PKG_CONFIG_DEPENDS := \
|
||||
CONFIG_NGINX_STUB_STATUS \
|
||||
CONFIG_NGINX_FLV \
|
||||
CONFIG_NGINX_SSL \
|
||||
CONFIG_NGINX_DAV \
|
||||
CONFIG_NGINX_LUA \
|
||||
CONFIG_NGINX_PCRE \
|
||||
CONFIG_NGINX_HTTP_CACHE \
|
||||
CONFIG_NGINX_HTTP_CHARSET \
|
||||
CONFIG_NGINX_HTTP_GZIP \
|
||||
CONFIG_NGINX_HTTP_SSI \
|
||||
CONFIG_NGINX_HTTP_USERID \
|
||||
CONFIG_NGINX_HTTP_ACCESS \
|
||||
CONFIG_NGINX_HTTP_AUTH_BASIC \
|
||||
CONFIG_NGINX_HTTP_AUTOINDEX \
|
||||
CONFIG_NGINX_HTTP_GEO \
|
||||
CONFIG_NGINX_HTTP_MAP \
|
||||
CONFIG_NGINX_HTTP_SPLIT_CLIENTS \
|
||||
CONFIG_NGINX_HTTP_REFERER \
|
||||
CONFIG_NGINX_HTTP_REWRITE \
|
||||
CONFIG_NGINX_HTTP_PROXY \
|
||||
CONFIG_NGINX_HTTP_FASTCGI \
|
||||
CONFIG_NGINX_HTTP_UWSGI \
|
||||
CONFIG_NGINX_HTTP_SCGI \
|
||||
CONFIG_NGINX_HTTP_MEMCACHED \
|
||||
CONFIG_NGINX_HTTP_LIMIT_CONN \
|
||||
CONFIG_NGINX_HTTP_LIMIT_REQ \
|
||||
CONFIG_NGINX_HTTP_EMPTY_GIF \
|
||||
CONFIG_NGINX_HTTP_BROWSER \
|
||||
CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/nginx
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=Nginx web server
|
||||
URL:=http://nginx.org/
|
||||
DEPENDS:=+NGINX_PCRE:libpcre +(NGINX_SSL||NGINX_HTTP_CACHE||NGINX_HTTP_AUTH_BASIC):libopenssl +NGINX_HTTP_GZIP:zlib +libpthread +NGINX_LUA:liblua
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/nginx/description
|
||||
nginx is an HTTP and reverse proxy server, as well as a mail proxy server,
|
||||
written by Igor Sysoev.
|
||||
endef
|
||||
|
||||
define Package/nginx/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
config_files=nginx.conf mime.types fastcgi_params koi-utf koi-win win-utf
|
||||
|
||||
define Package/nginx/conffiles
|
||||
/etc/nginx/
|
||||
endef
|
||||
|
||||
ADDITIONAL_MODULES:=
|
||||
ifeq ($(CONFIG_NGINX_NAXSI),y)
|
||||
ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src
|
||||
endif
|
||||
ifeq ($(CONFIG_IPV6),y)
|
||||
ADDITIONAL_MODULES += --with-ipv6
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_STUB_STATUS),y)
|
||||
ADDITIONAL_MODULES += --with-http_stub_status_module
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_FLV),y)
|
||||
ADDITIONAL_MODULES += --with-http_flv_module
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_SSL),y)
|
||||
ADDITIONAL_MODULES += --with-http_ssl_module
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_DAV),y)
|
||||
ADDITIONAL_MODULES += --with-http_dav_module
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_LUA),y)
|
||||
ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/lua-nginx
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_CACHE),y)
|
||||
ADDITIONAL_MODULES += --without-http-cache
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_PCRE),y)
|
||||
ADDITIONAL_MODULES += --without-pcre
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_CHARSET),y)
|
||||
ADDITIONAL_MODULES += --without-http_charset_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_GZIP),y)
|
||||
ADDITIONAL_MODULES += --without-http_gzip_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_SSI),y)
|
||||
ADDITIONAL_MODULES += --without-http_ssi_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_USERID),y)
|
||||
ADDITIONAL_MODULES += --without-http_userid_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_ACCESS),y)
|
||||
ADDITIONAL_MODULES += --without-http_access_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_AUTH_BASIC),y)
|
||||
ADDITIONAL_MODULES += --without-http_auth_basic_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_AUTOINDEX),y)
|
||||
ADDITIONAL_MODULES += --without-http_autoindex_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_GEO),y)
|
||||
ADDITIONAL_MODULES += --without-http_geo_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_MAP),y)
|
||||
ADDITIONAL_MODULES += --without-http_map_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_SPLIT_CLIENTS),y)
|
||||
ADDITIONAL_MODULES += --without-http_split_clients_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_REFERER),y)
|
||||
ADDITIONAL_MODULES += --without-http_referer_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_REWRITE),y)
|
||||
ADDITIONAL_MODULES += --without-http_rewrite_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_PROXY),y)
|
||||
ADDITIONAL_MODULES += --without-http_proxy_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_FASTCGI),y)
|
||||
ADDITIONAL_MODULES += --without-http_fastcgi_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_UWSGI),y)
|
||||
ADDITIONAL_MODULES += --without-http_uwsgi_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_SCGI),y)
|
||||
ADDITIONAL_MODULES += --without-http_scgi_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_MEMCACHED),y)
|
||||
ADDITIONAL_MODULES += --without-http_memcached_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_LIMIT_CONN),y)
|
||||
ADDITIONAL_MODULES += --without-http_limit_conn_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_LIMIT_REQ),y)
|
||||
ADDITIONAL_MODULES += --without-http_limit_req_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_EMPTY_GIF),y)
|
||||
ADDITIONAL_MODULES += --without-http_empty_gif_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_BROWSER),y)
|
||||
ADDITIONAL_MODULES += --without-http_browser_module
|
||||
endif
|
||||
ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH),y)
|
||||
ADDITIONAL_MODULES += --without-http_upstream_ip_hash_module
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_PROXYPROTOCOL),y)
|
||||
ADDITIONAL_MODULES += --with-proxy-protocol
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_SYSLOG),y)
|
||||
ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-syslog
|
||||
endif
|
||||
ifeq ($(CONFIG_NGINX_HTTP_UPSTREAM_CHECK),y)
|
||||
ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-upstream-check
|
||||
endif
|
||||
|
||||
define Build/Configure
|
||||
# TODO: fix --crossbuild
|
||||
(cd $(PKG_BUILD_DIR) ;\
|
||||
$(if $(CONFIG_NGINX_LUA),LUA_INC=$(STAGING_DIR)/usr/include LUA_LIB=$(STAGING_DIR)/usr/lib) \
|
||||
./configure \
|
||||
--crossbuild=Linux::$(ARCH) \
|
||||
--prefix=/usr \
|
||||
--conf-path=/etc/nginx/nginx.conf \
|
||||
$(ADDITIONAL_MODULES) \
|
||||
--error-log-path=/var/log/nginx/error.log \
|
||||
--pid-path=/var/run/nginx.pid \
|
||||
--lock-path=/var/lock/nginx.lock \
|
||||
--http-log-path=/var/log/nginx/access.log \
|
||||
--http-client-body-temp-path=/var/lib/nginx/body \
|
||||
--http-proxy-temp-path=/var/lib/nginx/proxy \
|
||||
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
|
||||
--with-cc="$(TARGET_CC)" \
|
||||
--with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
|
||||
--with-ld-opt="$(TARGET_LDFLAGS)" )
|
||||
endef
|
||||
|
||||
define Package/nginx/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/nginx
|
||||
$(INSTALL_DATA) $(addprefix $(PKG_INSTALL_DIR)/etc/nginx/,$(config_files)) $(1)/etc/nginx/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/nginx.init $(1)/etc/init.d/nginx
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
$(if $(CONFIG_NGINX_LUA),$(call Prepare/lua-nginx))
|
||||
$(if $(CONFIG_NGINX_NAXSI),$(call Prepare/nginx-naxsi))
|
||||
$(if $(CONFIG_NGINX_SYSLOG),$(call Prepare/nginx-syslog))
|
||||
$(if $(CONFIG_NGINX_HTTP_UPSTREAM_CHECK),$(call Prepare/nginx-upstream-check))
|
||||
endef
|
||||
|
||||
define Download/lua-nginx
|
||||
VERSION:=d3ab0edd45bffe1b9a36abdf5bff544de436ccee
|
||||
SUBDIR:=lua-nginx
|
||||
FILE:=lua-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz
|
||||
URL:=https://github.com/chaoslawful/lua-nginx-module.git
|
||||
PROTO:=git
|
||||
endef
|
||||
|
||||
define Prepare/lua-nginx
|
||||
$(eval $(call Download,lua-nginx))
|
||||
gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
|
||||
$(call PatchDir,$(PKG_BUILD_DIR),./patches-lua-nginx)
|
||||
endef
|
||||
|
||||
define Download/nginx-upstream-check
|
||||
VERSION:=d40b9f956d9d978005bb15616d2f283d4e3d2031
|
||||
SUBDIR:=nginx-upstream-check
|
||||
FILE:=nginx-upstream-check-$(PKG_VERSION)-$$(VERSION).tar.gz
|
||||
URL:=https://github.com/yaoweibin/nginx_upstream_check_module.git
|
||||
PROTO:=git
|
||||
endef
|
||||
|
||||
define Prepare/nginx-upstream-check
|
||||
$(eval $(call Download,nginx-upstream-check))
|
||||
gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
|
||||
$(call PatchDir,$(PKG_BUILD_DIR),./patches-nginx-upstream-check)
|
||||
endef
|
||||
|
||||
|
||||
define Package/nginx-naxsi
|
||||
MENU:=1
|
||||
$(call Package/nginx)
|
||||
TITLE+= nginx-naxsi
|
||||
DEPENDS:=nginx
|
||||
endef
|
||||
|
||||
define Package/nginx-naxsi/description
|
||||
NGINX WAF NAXSI
|
||||
endef
|
||||
|
||||
define Package/nginx-proxyprotocol
|
||||
MENU:=1
|
||||
$(call Package/nginx)
|
||||
TITLE+= nginx-proxyprotocol
|
||||
DEPENDS:=nginx
|
||||
endef
|
||||
|
||||
define Package/nginx-proxyprotocol/description
|
||||
IMPLEMENT Proxy Protocol
|
||||
endef
|
||||
|
||||
define Package/nginx-syslog
|
||||
MENU:=1
|
||||
$(call Package/nginx)
|
||||
TITLE+= nginx-syslog
|
||||
DEPENDS:=nginx
|
||||
endef
|
||||
|
||||
define Package/nginx-syslog/description
|
||||
IMPLEMENT Syslog Protocol
|
||||
endef
|
||||
|
||||
define Download/nginx-naxsi
|
||||
VERSION:=34dcb45fe4fdcb144c5258d83672f8e1e1c8db2e
|
||||
SUBDIR:=nginx-naxsi
|
||||
FILE:=nginx-naxsi-module-$(PKG_VERSION)-$$(VERSION).tar.gz
|
||||
URL:=https://github.com/nbs-system/naxsi.git
|
||||
PROTO:=git
|
||||
endef
|
||||
|
||||
define Prepare/nginx-naxsi
|
||||
$(eval $(call Download,nginx-naxsi))
|
||||
gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
|
||||
endef
|
||||
|
||||
define Package/nginx-naxsi/install
|
||||
$(INSTALL_DIR) $(1)/etc/nginx
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx
|
||||
chmod 0640 $(1)/etc/nginx/naxsi_core.rules
|
||||
endef
|
||||
|
||||
define Download/nginx-syslog
|
||||
VERSION:=7abf48e52552c40a21463e1a8c608e0e575261cd
|
||||
SUBDIR:=nginx-syslog
|
||||
FILE:=nginx-syslog-module-$(PKG_VERSION)-$$(VERSION).tar.gz
|
||||
URL:=https://github.com/splitice/nginx_syslog_patch.git
|
||||
PROTO:=git
|
||||
endef
|
||||
|
||||
define Prepare/nginx-syslog
|
||||
$(eval $(call Download,nginx-syslog))
|
||||
gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
|
||||
endef
|
||||
|
||||
define Package/nginx-proxyprotocol/install
|
||||
$(INSTALL_DIR) $(1)/etc/nginx
|
||||
$(INSTALL_BIN) ./files/nginx.proxyprotocol.example $(1)/etc/nginx/nginx.conf.proxyprotocol
|
||||
chmod 0640 $(1)/etc/nginx/nginx.conf.proxyprotocol
|
||||
endef
|
||||
|
||||
define Package/nginx-syslog/install
|
||||
$(INSTALL_DIR) $(1)/etc/nginx
|
||||
$(INSTALL_BIN) ./files/nginx.syslog.example $(1)/etc/nginx/nginx.conf.syslog
|
||||
chmod 0640 $(1)/etc/nginx/nginx.conf.syslog
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,nginx))
|
||||
$(eval $(call BuildPackage,nginx-naxsi))
|
||||
$(eval $(call BuildPackage,nginx-proxyprotocol))
|
||||
$(eval $(call BuildPackage,nginx-syslog))
|
||||
|
24
net/nginx/files/nginx.init
Normal file
24
net/nginx/files/nginx.init
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2009-2012 OpenWrt.org
|
||||
|
||||
START=50
|
||||
NGINX_BIN=/usr/sbin/nginx
|
||||
|
||||
start() {
|
||||
mkdir -p /var/log/nginx
|
||||
mkdir -p /var/lib/nginx
|
||||
$NGINX_BIN
|
||||
}
|
||||
|
||||
stop() {
|
||||
$NGINX_BIN -s stop
|
||||
}
|
||||
|
||||
reload() {
|
||||
$NGINX_BIN -s reload
|
||||
}
|
||||
|
||||
shutdown() {
|
||||
$NGINX_BIN -s quit
|
||||
}
|
||||
|
40
net/nginx/files/nginx.proxyprotocol.example
Normal file
40
net/nginx/files/nginx.proxyprotocol.example
Normal file
|
@ -0,0 +1,40 @@
|
|||
worker_processes 1;
|
||||
pid /tmp/nginx.pid;
|
||||
daemon off;
|
||||
master_process off;
|
||||
error_log stderr debug_core;
|
||||
|
||||
events {
|
||||
debug_connection <YOUR IPv4>;
|
||||
debug_connection <YOUR IPV6>;
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
default_type application/octet-stream;
|
||||
client_body_temp_path /tmp/body 1;
|
||||
|
||||
access_log /tmp/nginx_access.log;
|
||||
|
||||
server {
|
||||
# listen 8082 ssl;
|
||||
# proxy protocol configuration for nginx 1.4.x:
|
||||
listen 8082 accept_proxy_protocol=on;
|
||||
# same with spdy enabled:
|
||||
# listen 8082 spdy ssl accept_proxy_protocol=on;
|
||||
listen [::]:8082 ipv6only=on;
|
||||
ssl_certificate /your/certificate;
|
||||
ssl_certificate_key /your/key;
|
||||
server_name localhost;
|
||||
# proxy protocol configuration for nginx 1.2.x:
|
||||
# accept_proxy_protocol on;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8084;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_connect_timeout 10s;
|
||||
proxy_read_timeout 10s;
|
||||
send_proxy_protocol on;
|
||||
}
|
||||
}
|
||||
}
|
59
net/nginx/files/nginx.syslog.example
Normal file
59
net/nginx/files/nginx.syslog.example
Normal file
|
@ -0,0 +1,59 @@
|
|||
worker_processes 1;
|
||||
|
||||
syslog local6 nginx;
|
||||
|
||||
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"';
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
#send the log to syslog and file.
|
||||
access_log syslog:notice|logs/host1.access.log main;
|
||||
|
||||
# pre 1.5.x
|
||||
error_log syslog:notice|logs/host1.error.log;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.example.com;
|
||||
|
||||
access_log syslog:warn|logs/host2.access.log main;
|
||||
error_log syslog:warn|logs/host2.error.log;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.test.com;
|
||||
|
||||
#send the log just to syslog.
|
||||
access_log syslog:error main;
|
||||
error_log syslog:error;
|
||||
|
||||
location / {
|
||||
root html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
}
|
21
net/nginx/patches-lua-nginx/300-ldl.patch
Normal file
21
net/nginx/patches-lua-nginx/300-ldl.patch
Normal file
|
@ -0,0 +1,21 @@
|
|||
--- a/lua-nginx/config
|
||||
+++ b/lua-nginx/config
|
||||
@@ -1,5 +1,5 @@
|
||||
ngx_feature="Lua library"
|
||||
-ngx_feature_libs="-llua -lm"
|
||||
+ngx_feature_libs="-llua -lm -ldl"
|
||||
ngx_feature_name=
|
||||
ngx_feature_run=no
|
||||
ngx_feature_incs="#include <lauxlib.h>"
|
||||
@@ -47,9 +47,9 @@ else
|
||||
ngx_feature="Lua library in $LUA_LIB and $LUA_INC (specified by the LUA_LIB and LUA_INC env)"
|
||||
ngx_feature_path="$LUA_INC"
|
||||
if [ $NGX_RPATH = YES ]; then
|
||||
- ngx_feature_libs="-R$LUA_LIB -L$LUA_LIB -llua -lm"
|
||||
+ ngx_feature_libs="-R$LUA_LIB -L$LUA_LIB -llua -lm -ldl"
|
||||
else
|
||||
- ngx_feature_libs="-L$LUA_LIB -llua -lm"
|
||||
+ ngx_feature_libs="-L$LUA_LIB -llua -lm -ldl"
|
||||
fi
|
||||
|
||||
. auto/feature
|
209
net/nginx/patches-nginx-upstream-check/check_1.2.6+.patch
Normal file
209
net/nginx/patches-nginx-upstream-check/check_1.2.6+.patch
Normal file
|
@ -0,0 +1,209 @@
|
|||
diff --git a/src/http/modules/ngx_http_upstream_ip_hash_module.c b/src/http/modules/ngx_http_upstream_ip_hash_module.c
|
||||
index 89ccc2b..a552044 100644
|
||||
--- a/src/http/modules/ngx_http_upstream_ip_hash_module.c
|
||||
+++ b/src/http/modules/ngx_http_upstream_ip_hash_module.c
|
||||
@@ -9,6 +9,10 @@
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_http.h>
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+#include "ngx_http_upstream_check_handler.h"
|
||||
+#endif
|
||||
+
|
||||
|
||||
typedef struct {
|
||||
/* the round robin data must be first */
|
||||
@@ -208,6 +212,12 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
|
||||
|
||||
if (!peer->down) {
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
|
||||
+ "get ip_hash peer, check_index: %ui",
|
||||
+ peer->check_index);
|
||||
+ if (!ngx_http_check_peer_down(peer->check_index)) {
|
||||
+#endif
|
||||
if (peer->max_fails == 0 || peer->fails < peer->max_fails) {
|
||||
break;
|
||||
}
|
||||
@@ -216,6 +226,9 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
|
||||
peer->checked = now;
|
||||
break;
|
||||
}
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ }
|
||||
+#endif
|
||||
}
|
||||
|
||||
iphp->rrp.tried[n] |= m;
|
||||
diff --git a/src/http/modules/ngx_http_upstream_least_conn_module.c b/src/http/modules/ngx_http_upstream_least_conn_module.c
|
||||
index 21156ae..c57393d 100644
|
||||
--- a/src/http/modules/ngx_http_upstream_least_conn_module.c
|
||||
+++ b/src/http/modules/ngx_http_upstream_least_conn_module.c
|
||||
@@ -9,6 +9,10 @@
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_http.h>
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+#include "ngx_http_upstream_check_handler.h"
|
||||
+#endif
|
||||
+
|
||||
|
||||
typedef struct {
|
||||
ngx_uint_t *conns;
|
||||
@@ -203,6 +207,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
|
||||
continue;
|
||||
}
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
|
||||
+ "get least_conn peer, check_index: %ui",
|
||||
+ peer->check_index);
|
||||
+
|
||||
+ if (ngx_http_check_peer_down(peer->check_index)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
if (peer->max_fails
|
||||
&& peer->fails >= peer->max_fails
|
||||
&& now - peer->checked <= peer->fail_timeout)
|
||||
@@ -256,6 +270,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data)
|
||||
continue;
|
||||
}
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
|
||||
+ "get least_conn peer, check_index: %ui",
|
||||
+ peer->check_index);
|
||||
+
|
||||
+ if (ngx_http_check_peer_down(peer->check_index)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
if (lcp->conns[i] * best->weight != lcp->conns[p] * peer->weight) {
|
||||
continue;
|
||||
}
|
||||
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
|
||||
index 4b78cff..f077b46 100644
|
||||
--- a/src/http/ngx_http_upstream_round_robin.c
|
||||
+++ b/src/http/ngx_http_upstream_round_robin.c
|
||||
@@ -9,6 +9,9 @@
|
||||
#include <ngx_core.h>
|
||||
#include <ngx_http.h>
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+#include "ngx_http_upstream_check_handler.h"
|
||||
+#endif
|
||||
|
||||
static ngx_int_t ngx_http_upstream_cmp_servers(const void *one,
|
||||
const void *two);
|
||||
@@ -87,7 +90,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
|
||||
peers->peer[n].weight = server[i].weight;
|
||||
peers->peer[n].effective_weight = server[i].weight;
|
||||
peers->peer[n].current_weight = 0;
|
||||
- n++;
|
||||
+
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ if (!server[i].down) {
|
||||
+ peers->peer[n].check_index =
|
||||
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
|
||||
+ }
|
||||
+ else {
|
||||
+ peers->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
|
||||
+ }
|
||||
+#endif
|
||||
+ n++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +158,17 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
|
||||
backup->peer[n].max_fails = server[i].max_fails;
|
||||
backup->peer[n].fail_timeout = server[i].fail_timeout;
|
||||
backup->peer[n].down = server[i].down;
|
||||
+
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ if (!server[i].down) {
|
||||
+ backup->peer[n].check_index =
|
||||
+ ngx_http_check_add_peer(cf, us, &server[i].addrs[j]);
|
||||
+ }
|
||||
+ else {
|
||||
+ backup->peer[n].check_index = (ngx_uint_t) NGX_ERROR;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@@ -206,6 +230,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
|
||||
peers->peer[i].current_weight = 0;
|
||||
peers->peer[i].max_fails = 1;
|
||||
peers->peer[i].fail_timeout = 10;
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
|
||||
+#endif
|
||||
}
|
||||
|
||||
us->peer.data = peers;
|
||||
@@ -323,6 +350,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
|
||||
peers->peer[0].current_weight = 0;
|
||||
peers->peer[0].max_fails = 1;
|
||||
peers->peer[0].fail_timeout = 10;
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ peers->peer[0].check_index = (ngx_uint_t) NGX_ERROR;
|
||||
+#endif
|
||||
|
||||
} else {
|
||||
|
||||
@@ -356,6 +386,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r,
|
||||
peers->peer[i].current_weight = 0;
|
||||
peers->peer[i].max_fails = 1;
|
||||
peers->peer[i].fail_timeout = 10;
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ peers->peer[i].check_index = (ngx_uint_t) NGX_ERROR;
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,6 +467,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ if (ngx_http_check_peer_down(peer->check_index)) {
|
||||
+ goto failed;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
} else {
|
||||
|
||||
/* there are several peers */
|
||||
@@ -531,6 +570,12 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp)
|
||||
continue;
|
||||
}
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ if (ngx_http_check_peer_down(peer->check_index)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
if (peer->max_fails
|
||||
&& peer->fails >= peer->max_fails
|
||||
&& now - peer->checked <= peer->fail_timeout)
|
||||
diff --git a/src/http/ngx_http_upstream_round_robin.h b/src/http/ngx_http_upstream_round_robin.h
|
||||
index 3f8cbf8..1613168 100644
|
||||
--- a/src/http/ngx_http_upstream_round_robin.h
|
||||
+++ b/src/http/ngx_http_upstream_round_robin.h
|
||||
@@ -30,6 +30,10 @@ typedef struct {
|
||||
ngx_uint_t max_fails;
|
||||
time_t fail_timeout;
|
||||
|
||||
+#if (NGX_UPSTREAM_CHECK_MODULE)
|
||||
+ ngx_uint_t check_index;
|
||||
+#endif
|
||||
+
|
||||
ngx_uint_t down; /* unsigned down:1; */
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
107
net/nginx/patches/101-feature_test_fix.patch
Normal file
107
net/nginx/patches/101-feature_test_fix.patch
Normal file
|
@ -0,0 +1,107 @@
|
|||
--- a/auto/cc/name
|
||||
+++ b/auto/cc/name
|
||||
@@ -7,7 +7,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
|
||||
|
||||
ngx_feature="C compiler"
|
||||
ngx_feature_name=
|
||||
- ngx_feature_run=yes
|
||||
+ ngx_feature_run=
|
||||
ngx_feature_incs=
|
||||
ngx_feature_path=
|
||||
ngx_feature_libs=
|
||||
--- a/auto/cc/conf
|
||||
+++ b/auto/cc/conf
|
||||
@@ -155,7 +155,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
|
||||
else
|
||||
ngx_feature="C99 variadic macros"
|
||||
ngx_feature_name="NGX_HAVE_C99_VARIADIC_MACROS"
|
||||
- ngx_feature_run=yes
|
||||
+ ngx_feature_run=no
|
||||
ngx_feature_incs="#include <stdio.h>
|
||||
#define var(dummy, ...) sprintf(__VA_ARGS__)"
|
||||
ngx_feature_path=
|
||||
@@ -169,7 +169,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
|
||||
|
||||
ngx_feature="gcc variadic macros"
|
||||
ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
|
||||
- ngx_feature_run=yes
|
||||
+ ngx_feature_run=no
|
||||
ngx_feature_incs="#include <stdio.h>
|
||||
#define var(dummy, args...) sprintf(args)"
|
||||
ngx_feature_path=
|
||||
--- a/auto/os/linux
|
||||
+++ b/auto/os/linux
|
||||
@@ -48,7 +48,7 @@ fi
|
||||
|
||||
ngx_feature="epoll"
|
||||
ngx_feature_name="NGX_HAVE_EPOLL"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sys/epoll.h>"
|
||||
ngx_feature_path=
|
||||
ngx_feature_libs=
|
||||
@@ -73,7 +73,7 @@ fi
|
||||
CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE"
|
||||
ngx_feature="sendfile()"
|
||||
ngx_feature_name="NGX_HAVE_SENDFILE"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sys/sendfile.h>
|
||||
#include <errno.h>"
|
||||
ngx_feature_path=
|
||||
@@ -94,7 +94,7 @@ fi
|
||||
CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
|
||||
ngx_feature="sendfile64()"
|
||||
ngx_feature_name="NGX_HAVE_SENDFILE64"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sys/sendfile.h>
|
||||
#include <errno.h>"
|
||||
ngx_feature_path=
|
||||
@@ -112,7 +112,7 @@ ngx_include="sys/prctl.h"; . auto/includ
|
||||
|
||||
ngx_feature="prctl(PR_SET_DUMPABLE)"
|
||||
ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sys/prctl.h>"
|
||||
ngx_feature_path=
|
||||
ngx_feature_libs=
|
||||
--- a/auto/unix
|
||||
+++ b/auto/unix
|
||||
@@ -618,7 +618,7 @@ ngx_feature_test="void *p; p = memalign(
|
||||
|
||||
ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
|
||||
ngx_feature_name="NGX_HAVE_MAP_ANON"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sys/mman.h>"
|
||||
ngx_feature_path=
|
||||
ngx_feature_libs=
|
||||
@@ -631,7 +631,7 @@ ngx_feature_test="void *p;
|
||||
|
||||
ngx_feature='mmap("/dev/zero", MAP_SHARED)'
|
||||
ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>"
|
||||
@@ -646,7 +646,7 @@ ngx_feature_test='void *p; int fd;
|
||||
|
||||
ngx_feature="System V shared memory"
|
||||
ngx_feature_name="NGX_HAVE_SYSVSHM"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <sys/ipc.h>
|
||||
#include <sys/shm.h>"
|
||||
ngx_feature_path=
|
||||
@@ -660,7 +660,7 @@ ngx_feature_test="int id;
|
||||
|
||||
ngx_feature="POSIX semaphores"
|
||||
ngx_feature_name="NGX_HAVE_POSIX_SEM"
|
||||
-ngx_feature_run=yes
|
||||
+ngx_feature_run=no
|
||||
ngx_feature_incs="#include <semaphore.h>"
|
||||
ngx_feature_path=
|
||||
ngx_feature_libs=
|
26
net/nginx/patches/102-sizeof_test_fix.patch
Normal file
26
net/nginx/patches/102-sizeof_test_fix.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
--- a/auto/types/sizeof
|
||||
+++ b/auto/types/sizeof
|
||||
@@ -25,8 +25,13 @@ $NGX_INCLUDE_UNISTD_H
|
||||
$NGX_INCLUDE_INTTYPES_H
|
||||
$NGX_INCLUDE_AUTO_CONFIG_H
|
||||
|
||||
+char object_code_block[] = {
|
||||
+ '\n', 'e', '4', 'V', 'A',
|
||||
+ '0', 'x', ('0' + sizeof($ngx_type)),
|
||||
+ 'Y', '3', 'p', 'M', '\n'
|
||||
+};
|
||||
+
|
||||
int main() {
|
||||
- printf("%d", (int) sizeof($ngx_type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -40,7 +45,7 @@ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&
|
||||
|
||||
|
||||
if [ -x $NGX_AUTOTEST ]; then
|
||||
- ngx_size=`$NGX_AUTOTEST`
|
||||
+ ngx_size=`sed -ne 's/^e4VA0x\(.\)Y3pM$/\1/p' < $NGX_AUTOTEST`
|
||||
echo " $ngx_size bytes"
|
||||
fi
|
||||
|
12
net/nginx/patches/103-sys_nerr.patch
Normal file
12
net/nginx/patches/103-sys_nerr.patch
Normal file
|
@ -0,0 +1,12 @@
|
|||
--- a/src/os/unix/ngx_errno.c
|
||||
+++ b/src/os/unix/ngx_errno.c
|
||||
@@ -8,6 +8,9 @@
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
|
||||
+#ifndef NGX_SYS_NERR
|
||||
+#define NGX_SYS_NERR 128
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* The strerror() messages are copied because:
|
18
net/nginx/patches/200-config.patch
Normal file
18
net/nginx/patches/200-config.patch
Normal file
|
@ -0,0 +1,18 @@
|
|||
--- a/conf/nginx.conf
|
||||
+++ b/conf/nginx.conf
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
-#user nobody;
|
||||
+user nobody nogroup;
|
||||
worker_processes 1;
|
||||
|
||||
#error_log logs/error.log;
|
||||
@@ -16,7 +16,7 @@ events {
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
- default_type application/octet-stream;
|
||||
+ #default_type application/octet-stream;
|
||||
|
||||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
# '$status $body_bytes_sent "$http_referer" '
|
33
net/nginx/patches/300-crosscompile_ccflags.patch
Normal file
33
net/nginx/patches/300-crosscompile_ccflags.patch
Normal file
|
@ -0,0 +1,33 @@
|
|||
--- a/auto/endianness
|
||||
+++ b/auto/endianness
|
||||
@@ -21,7 +21,7 @@ int main() {
|
||||
|
||||
END
|
||||
|
||||
-ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
|
||||
+ngx_test="$CC $NGX_CC_OPT $CC_TEST_FLAGS $CC_AUX_FLAGS \
|
||||
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
|
||||
|
||||
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
|
||||
--- a/auto/feature
|
||||
+++ b/auto/feature
|
||||
@@ -39,7 +39,7 @@ int main() {
|
||||
END
|
||||
|
||||
|
||||
-ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS $ngx_feature_inc_path \
|
||||
+ngx_test="$CC $NGX_CC_OPT $CC_TEST_FLAGS $CC_AUX_FLAGS $ngx_feature_inc_path \
|
||||
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_TEST_LD_OPT $ngx_feature_libs"
|
||||
|
||||
ngx_feature_inc_path=
|
||||
--- a/auto/include
|
||||
+++ b/auto/include
|
||||
@@ -27,7 +27,7 @@ int main() {
|
||||
END
|
||||
|
||||
|
||||
-ngx_test="$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
|
||||
+ngx_test="$CC $NGX_CC_OPT -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
|
||||
|
||||
eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
|
||||
|
1194
net/nginx/patches/400-nginx-1.4.x_proxy_protocol_patch_v2.patch
Normal file
1194
net/nginx/patches/400-nginx-1.4.x_proxy_protocol_patch_v2.patch
Normal file
File diff suppressed because it is too large
Load diff
698
net/nginx/patches/401-nginx-1.4.0-syslog.patch
Normal file
698
net/nginx/patches/401-nginx-1.4.0-syslog.patch
Normal file
|
@ -0,0 +1,698 @@
|
|||
Index: nginx-1.4.7/src/core/ngx_cycle.c
|
||||
===================================================================
|
||||
--- nginx-1.4.7.orig/src/core/ngx_cycle.c
|
||||
+++ nginx-1.4.7/src/core/ngx_cycle.c
|
||||
@@ -85,6 +85,12 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
|
||||
cycle->pool = pool;
|
||||
cycle->log = log;
|
||||
cycle->new_log.log_level = NGX_LOG_ERR;
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ cycle->new_log.facility = SYSLOG_FACILITY;
|
||||
+ cycle->new_log.facility = ERR_SYSLOG_PRIORITY;
|
||||
+ cycle->new_log.syslog_on = 0;
|
||||
+ cycle->new_log.syslog_set = 0;
|
||||
+#endif
|
||||
cycle->old_cycle = old_cycle;
|
||||
|
||||
cycle->conf_prefix.len = old_cycle->conf_prefix.len;
|
||||
Index: nginx-1.4.7/src/core/ngx_log.c
|
||||
===================================================================
|
||||
--- nginx-1.4.7.orig/src/core/ngx_log.c
|
||||
+++ nginx-1.4.7/src/core/ngx_log.c
|
||||
@@ -10,6 +10,15 @@
|
||||
|
||||
|
||||
static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+static char *ngx_set_syslog(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||
+void log_exit(ngx_cycle_t *cycle);
|
||||
+
|
||||
+typedef struct{
|
||||
+ ngx_str_t name;
|
||||
+ ngx_int_t macro;
|
||||
+} ngx_string_to_macro_t;
|
||||
+#endif
|
||||
|
||||
|
||||
static ngx_command_t ngx_errlog_commands[] = {
|
||||
@@ -21,6 +30,15 @@ static ngx_command_t ngx_errlog_command
|
||||
0,
|
||||
NULL},
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ {ngx_string("syslog"),
|
||||
+ NGX_MAIN_CONF|NGX_CONF_TAKE12,
|
||||
+ ngx_set_syslog,
|
||||
+ 0,
|
||||
+ 0,
|
||||
+ NULL},
|
||||
+#endif
|
||||
+
|
||||
ngx_null_command
|
||||
};
|
||||
|
||||
@@ -43,7 +61,11 @@ ngx_module_t ngx_errlog_module = {
|
||||
NULL, /* init thread */
|
||||
NULL, /* exit thread */
|
||||
NULL, /* exit process */
|
||||
- NULL, /* exit master */
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ log_exit, /* exit master */
|
||||
+#else
|
||||
+ NULL,
|
||||
+#endif
|
||||
NGX_MODULE_V1_PADDING
|
||||
};
|
||||
|
||||
@@ -52,6 +74,48 @@ static ngx_log_t ngx_log;
|
||||
static ngx_open_file_t ngx_log_file;
|
||||
ngx_uint_t ngx_use_stderr = 1;
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+static ngx_string_to_macro_t ngx_syslog_facilities[] = {
|
||||
+ {ngx_string("auth"), LOG_AUTH},
|
||||
+#if !(NGX_SOLARIS)
|
||||
+ {ngx_string("authpriv"), LOG_AUTHPRIV},
|
||||
+#endif
|
||||
+ {ngx_string("cron"), LOG_CRON},
|
||||
+ {ngx_string("daemon"), LOG_DAEMON},
|
||||
+#if !(NGX_SOLARIS)
|
||||
+ {ngx_string("ftp"), LOG_FTP},
|
||||
+#endif
|
||||
+ {ngx_string("kern"), LOG_KERN},
|
||||
+ {ngx_string("local0"), LOG_LOCAL0},
|
||||
+ {ngx_string("local1"), LOG_LOCAL1},
|
||||
+ {ngx_string("local2"), LOG_LOCAL2},
|
||||
+ {ngx_string("local3"), LOG_LOCAL3},
|
||||
+ {ngx_string("local4"), LOG_LOCAL4},
|
||||
+ {ngx_string("local5"), LOG_LOCAL5},
|
||||
+ {ngx_string("local6"), LOG_LOCAL6},
|
||||
+ {ngx_string("local7"), LOG_LOCAL7},
|
||||
+ {ngx_string("lpr"), LOG_LPR},
|
||||
+ {ngx_string("mail"), LOG_MAIL},
|
||||
+ {ngx_string("news"), LOG_NEWS},
|
||||
+ {ngx_string("syslog"), LOG_SYSLOG},
|
||||
+ {ngx_string("user"), LOG_USER},
|
||||
+ {ngx_string("uucp"), LOG_UUCP},
|
||||
+ { ngx_null_string, 0}
|
||||
+};
|
||||
+
|
||||
+static ngx_string_to_macro_t ngx_syslog_priorities[] = {
|
||||
+ {ngx_string("emerg"), LOG_EMERG},
|
||||
+ {ngx_string("alert"), LOG_ALERT},
|
||||
+ {ngx_string("crit"), LOG_CRIT},
|
||||
+ {ngx_string("error"), LOG_ERR},
|
||||
+ {ngx_string("err"), LOG_ERR},
|
||||
+ {ngx_string("warn"), LOG_WARNING},
|
||||
+ {ngx_string("notice"),LOG_NOTICE},
|
||||
+ {ngx_string("info"), LOG_INFO},
|
||||
+ {ngx_string("debug"), LOG_DEBUG},
|
||||
+ { ngx_null_string, 0}
|
||||
+};
|
||||
+#endif
|
||||
|
||||
static ngx_str_t err_levels[] = {
|
||||
ngx_null_string,
|
||||
@@ -89,11 +153,16 @@ ngx_log_error_core(ngx_uint_t level, ngx
|
||||
va_list args;
|
||||
#endif
|
||||
u_char *p, *last, *msg;
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ u_char *errstr_syslog;
|
||||
+#endif
|
||||
u_char errstr[NGX_MAX_ERROR_STR];
|
||||
|
||||
+#if !(NGX_ENABLE_SYSLOG)
|
||||
if (log->file->fd == NGX_INVALID_FILE) {
|
||||
return;
|
||||
}
|
||||
+#endif
|
||||
|
||||
last = errstr + NGX_MAX_ERROR_STR;
|
||||
|
||||
@@ -102,6 +171,10 @@ ngx_log_error_core(ngx_uint_t level, ngx
|
||||
|
||||
p = errstr + ngx_cached_err_log_time.len;
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ errstr_syslog = p;
|
||||
+#endif
|
||||
+
|
||||
p = ngx_slprintf(p, last, " [%V] ", &err_levels[level]);
|
||||
|
||||
/* pid#tid */
|
||||
@@ -140,11 +213,27 @@ ngx_log_error_core(ngx_uint_t level, ngx
|
||||
|
||||
ngx_linefeed(p);
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ if (log->file != NULL && log->file->name.len != 0) {
|
||||
(void) ngx_write_fd(log->file->fd, errstr, p - errstr);
|
||||
+ }
|
||||
+
|
||||
+ /* Don't send the debug level info to syslog */
|
||||
+ if (log->syslog_on && level < NGX_LOG_DEBUG) {
|
||||
+ /* write to syslog */
|
||||
+ syslog(log->priority, "%.*s", (int)(p - errstr_syslog), errstr_syslog);
|
||||
+ }
|
||||
+#else
|
||||
+ (void) ngx_write_fd(log->file->fd, errstr, p - errstr);
|
||||
+#endif
|
||||
|
||||
if (!ngx_use_stderr
|
||||
|| level > NGX_LOG_WARN
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ || (log->file != NULL && log->file->fd == ngx_stderr))
|
||||
+#else
|
||||
|| log->file->fd == ngx_stderr)
|
||||
+#endif
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -367,6 +456,50 @@ ngx_log_create(ngx_cycle_t *cycle, ngx_s
|
||||
}
|
||||
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ngx_int_t
|
||||
+ngx_log_get_priority(ngx_conf_t *cf, ngx_str_t *priority)
|
||||
+{
|
||||
+ ngx_int_t p = 0;
|
||||
+ ngx_uint_t n, match = 0;
|
||||
+
|
||||
+ for (n = 0; ngx_syslog_priorities[n].name.len != 0; n++) {
|
||||
+ if (ngx_strncmp(priority->data, ngx_syslog_priorities[n].name.data,
|
||||
+ ngx_syslog_priorities[n].name.len) == 0) {
|
||||
+ p = ngx_syslog_priorities[n].macro;
|
||||
+ match = 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!match) {
|
||||
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
+ "invalid syslog priority \"%V\"", priority);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return p;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+char *
|
||||
+ngx_log_set_priority(ngx_conf_t *cf, ngx_str_t *priority, ngx_log_t *log)
|
||||
+{
|
||||
+ log->priority = ERR_SYSLOG_PRIORITY;
|
||||
+
|
||||
+ if (priority->len == 0) {
|
||||
+ return NGX_CONF_OK;
|
||||
+ }
|
||||
+
|
||||
+ log->priority = ngx_log_get_priority(cf, priority);
|
||||
+ if (log->priority == (-1)) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ return NGX_CONF_OK;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
char *
|
||||
ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
|
||||
{
|
||||
@@ -429,6 +562,13 @@ static char *
|
||||
ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_str_t *value, name;
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ u_char *off = NULL;
|
||||
+ ngx_str_t priority;
|
||||
+
|
||||
+ ngx_str_null(&name);
|
||||
+ ngx_str_null(&priority);
|
||||
+#endif
|
||||
|
||||
if (cf->cycle->new_log.file) {
|
||||
return "is duplicate";
|
||||
@@ -436,7 +576,44 @@ ngx_error_log(ngx_conf_t *cf, ngx_comman
|
||||
|
||||
value = cf->args->elts;
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
|
||||
+ if (!cf->cycle->new_log.syslog_set) {
|
||||
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
+ "You must set the syslog directive and enable it first.");
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ cf->cycle->new_log.syslog_on = 1;
|
||||
+
|
||||
+ if (value[1].data[sizeof("syslog") - 1] == ':') {
|
||||
+ priority.len = value[1].len - sizeof("syslog");
|
||||
+ priority.data = value[1].data + sizeof("syslog");
|
||||
+
|
||||
+ off = (u_char *)ngx_strchr(priority.data, (int) '|');
|
||||
+ if (off != NULL) {
|
||||
+ priority.len = off - priority.data;
|
||||
+
|
||||
+ off++;
|
||||
+ name.len = value[1].data + value[1].len - off;
|
||||
+ name.data = off;
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ if (value[1].len > sizeof("syslog")) {
|
||||
+ name.len = value[1].len - sizeof("syslog");
|
||||
+ name.data = value[1].data + sizeof("syslog");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (ngx_log_set_priority(cf, &priority, &cf->cycle->new_log) == NGX_CONF_ERROR) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (ngx_strcmp(value[1].data, "stderr") == 0) {
|
||||
+#else
|
||||
if (ngx_strcmp(value[1].data, "stderr") == 0) {
|
||||
+#endif
|
||||
ngx_str_null(&name);
|
||||
|
||||
} else {
|
||||
@@ -457,3 +634,63 @@ ngx_error_log(ngx_conf_t *cf, ngx_comman
|
||||
|
||||
return ngx_log_set_levels(cf, &cf->cycle->new_log);
|
||||
}
|
||||
+
|
||||
+
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+
|
||||
+#define SYSLOG_IDENT_NAME "nginx"
|
||||
+
|
||||
+static char *
|
||||
+ngx_set_syslog(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
+{
|
||||
+ char *program;
|
||||
+ ngx_str_t *value;
|
||||
+ ngx_int_t facility, match = 0;
|
||||
+ ngx_uint_t n;
|
||||
+
|
||||
+ value = cf->args->elts;
|
||||
+
|
||||
+ if (cf->cycle->new_log.syslog_set) {
|
||||
+ return "is duplicate";
|
||||
+ }
|
||||
+
|
||||
+ cf->cycle->new_log.syslog_set = 1;
|
||||
+
|
||||
+ for (n = 0; ngx_syslog_facilities[n].name.len != 0; n++) {
|
||||
+ if (ngx_strncmp(value[1].data, ngx_syslog_facilities[n].name.data,
|
||||
+ ngx_syslog_facilities[n].name.len) == 0) {
|
||||
+ facility = ngx_syslog_facilities[n].macro;
|
||||
+ match = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (match) {
|
||||
+ cf->cycle->new_log.facility = facility;
|
||||
+ cf->cycle->new_log.priority = ERR_SYSLOG_PRIORITY;
|
||||
+ }
|
||||
+ else {
|
||||
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
+ "invalid syslog facility \"%V\"", &value[1]);
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ program = SYSLOG_IDENT_NAME;
|
||||
+ if (cf->args->nelts > 2) {
|
||||
+ program = (char *) value[2].data;
|
||||
+ }
|
||||
+
|
||||
+ openlog(program, LOG_ODELAY, facility);
|
||||
+
|
||||
+ return NGX_CONF_OK;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void log_exit(ngx_cycle_t *cycle)
|
||||
+{
|
||||
+ if (cycle->new_log.syslog_set) {
|
||||
+ closelog();
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
Index: nginx-1.4.7/src/core/ngx_log.h
|
||||
===================================================================
|
||||
--- nginx-1.4.7.orig/src/core/ngx_log.h
|
||||
+++ nginx-1.4.7/src/core/ngx_log.h
|
||||
@@ -12,6 +12,13 @@
|
||||
#include <ngx_config.h>
|
||||
#include <ngx_core.h>
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+#include <syslog.h>
|
||||
+
|
||||
+#define SYSLOG_FACILITY LOG_LOCAL5
|
||||
+#define ERR_SYSLOG_PRIORITY LOG_ERR
|
||||
+#endif
|
||||
+
|
||||
|
||||
#define NGX_LOG_STDERR 0
|
||||
#define NGX_LOG_EMERG 1
|
||||
@@ -61,6 +68,13 @@ struct ngx_log_s {
|
||||
*/
|
||||
|
||||
char *action;
|
||||
+
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ ngx_int_t priority;
|
||||
+ ngx_int_t facility;
|
||||
+ unsigned syslog_on:1; /* unsigned :1 syslog_on */
|
||||
+ unsigned syslog_set:1; /*unsigned :1 syslog_set */
|
||||
+#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -221,6 +235,10 @@ void ngx_cdecl ngx_log_debug_core(ngx_lo
|
||||
|
||||
ngx_log_t *ngx_log_init(u_char *prefix);
|
||||
ngx_log_t *ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name);
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ngx_int_t ngx_log_get_priority(ngx_conf_t *cf, ngx_str_t *priority);
|
||||
+char * ngx_log_set_priority(ngx_conf_t *cf, ngx_str_t *priority, ngx_log_t *log);
|
||||
+#endif
|
||||
char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
|
||||
void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...);
|
||||
void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...);
|
||||
Index: nginx-1.4.7/src/http/modules/ngx_http_log_module.c
|
||||
===================================================================
|
||||
--- nginx-1.4.7.orig/src/http/modules/ngx_http_log_module.c
|
||||
+++ nginx-1.4.7/src/http/modules/ngx_http_log_module.c
|
||||
@@ -13,6 +13,11 @@
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+#include <syslog.h>
|
||||
+
|
||||
+#define HTTP_SYSLOG_PRIORITY LOG_NOTICE
|
||||
+#endif
|
||||
|
||||
typedef struct ngx_http_log_op_s ngx_http_log_op_t;
|
||||
|
||||
@@ -67,6 +72,11 @@ typedef struct {
|
||||
time_t disk_full_time;
|
||||
time_t error_log_time;
|
||||
ngx_http_log_fmt_t *format;
|
||||
+
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ ngx_int_t priority;
|
||||
+ unsigned syslog_on:1; /* unsigned :1 syslog_on */
|
||||
+#endif
|
||||
} ngx_http_log_t;
|
||||
|
||||
|
||||
@@ -348,6 +358,14 @@ ngx_http_log_write(ngx_http_request_t *r
|
||||
time_t now;
|
||||
ssize_t n;
|
||||
ngx_err_t err;
|
||||
+
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ n = 0;
|
||||
+ if (log->syslog_on) {
|
||||
+ syslog(log->priority, "%.*s", (int)len, buf);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
#if (NGX_ZLIB)
|
||||
ngx_http_log_buf_t *buffer;
|
||||
#endif
|
||||
@@ -355,6 +373,9 @@ ngx_http_log_write(ngx_http_request_t *r
|
||||
if (log->script == NULL) {
|
||||
name = log->file->name.data;
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ if (name != NULL) {
|
||||
+#endif
|
||||
#if (NGX_ZLIB)
|
||||
buffer = log->file->data;
|
||||
|
||||
@@ -367,7 +388,11 @@ ngx_http_log_write(ngx_http_request_t *r
|
||||
#else
|
||||
n = ngx_write_fd(log->file->fd, buf, len);
|
||||
#endif
|
||||
-
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ } else {
|
||||
+ n = len;
|
||||
+ }
|
||||
+#endif
|
||||
} else {
|
||||
name = NULL;
|
||||
n = ngx_http_log_script_write(r, log->script, &name, buf, len);
|
||||
@@ -1068,6 +1093,10 @@ ngx_http_log_merge_loc_conf(ngx_conf_t *
|
||||
log->script = NULL;
|
||||
log->disk_full_time = 0;
|
||||
log->error_log_time = 0;
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ log->priority = HTTP_SYSLOG_PRIORITY;
|
||||
+ log->syslog_on = 0;
|
||||
+#endif
|
||||
|
||||
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
||||
fmt = lmcf->formats.elts;
|
||||
@@ -1096,6 +1125,13 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
|
||||
ngx_http_log_main_conf_t *lmcf;
|
||||
ngx_http_script_compile_t sc;
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ u_char *off;
|
||||
+ ngx_str_t priority;
|
||||
+ ngx_uint_t syslog_on = 0;
|
||||
+ name = priority = (ngx_str_t)ngx_null_string;
|
||||
+#endif
|
||||
+
|
||||
value = cf->args->elts;
|
||||
|
||||
if (ngx_strcmp(value[1].data, "off") == 0) {
|
||||
@@ -1108,6 +1144,38 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
|
||||
"invalid parameter \"%V\"", &value[2]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ else if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
|
||||
+ if (!cf->cycle->new_log.syslog_set) {
|
||||
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
+ "You must set the syslog directive and enable it first.");
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ syslog_on = 1;
|
||||
+ if (value[1].data[sizeof("syslog") - 1] == ':') {
|
||||
+ priority.len = value[1].len - sizeof("syslog");
|
||||
+ priority.data = value[1].data + sizeof("syslog");
|
||||
+
|
||||
+ off = (u_char*) ngx_strchr(priority.data, '|');
|
||||
+ if (off != NULL) {
|
||||
+ priority.len = off - priority.data;
|
||||
+
|
||||
+ off++;
|
||||
+ name.len = value[1].data + value[1].len - off;
|
||||
+ name.data = off;
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ if (value[1].len > sizeof("syslog")) {
|
||||
+ name.len = value[1].len - sizeof("syslog");
|
||||
+ name.data = value[1].data + sizeof("syslog");
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ name = value[1];
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
if (llcf->logs == NULL) {
|
||||
llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
|
||||
@@ -1125,6 +1193,52 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
|
||||
|
||||
ngx_memzero(log, sizeof(ngx_http_log_t));
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ log->syslog_on = syslog_on;
|
||||
+
|
||||
+ if (priority.len == 0) {
|
||||
+ log->priority = HTTP_SYSLOG_PRIORITY;
|
||||
+ }
|
||||
+ else {
|
||||
+ log->priority = ngx_log_get_priority(cf, &priority);
|
||||
+ }
|
||||
+
|
||||
+ if (name.len != 0) {
|
||||
+ n = ngx_http_script_variables_count(&name);
|
||||
+
|
||||
+ if (n == 0) {
|
||||
+ log->file = ngx_conf_open_file(cf->cycle, &name);
|
||||
+ if (log->file == NULL) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (ngx_conf_full_name(cf->cycle, &name, 0) != NGX_OK) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+ log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
|
||||
+ if (log->script == NULL) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
||||
+ sc.cf = cf;
|
||||
+ sc.source = &name;
|
||||
+ sc.lengths = &log->script->lengths;
|
||||
+ sc.values = &log->script->values;
|
||||
+ sc.variables = n;
|
||||
+ sc.complete_lengths = 1;
|
||||
+ sc.complete_values = 1;
|
||||
+ if (ngx_http_script_compile(&sc) != NGX_OK) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ log->file = ngx_conf_open_file(cf->cycle, &name);
|
||||
+ if (log->file == NULL) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+ }
|
||||
+#else
|
||||
n = ngx_http_script_variables_count(&value[1]);
|
||||
|
||||
if (n == 0) {
|
||||
@@ -1157,6 +1271,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
if (cf->args->nelts >= 3) {
|
||||
name = value[2];
|
||||
Index: nginx-1.4.7/src/http/ngx_http_core_module.c
|
||||
===================================================================
|
||||
--- nginx-1.4.7.orig/src/http/ngx_http_core_module.c
|
||||
+++ nginx-1.4.7/src/http/ngx_http_core_module.c
|
||||
@@ -1462,6 +1462,9 @@ ngx_http_update_location_config(ngx_http
|
||||
|
||||
if (r == r->main) {
|
||||
ngx_http_set_connection_log(r->connection, clcf->error_log);
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ r->connection->log->priority = clcf->error_log->priority;
|
||||
+#endif
|
||||
}
|
||||
|
||||
if ((ngx_io.flags & NGX_IO_SENDFILE) && clcf->sendfile) {
|
||||
@@ -4901,6 +4904,15 @@ ngx_http_core_error_log(ngx_conf_t *cf,
|
||||
|
||||
ngx_str_t *value, name;
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ u_char *off = NULL;
|
||||
+ ngx_int_t syslog_on = 0;
|
||||
+ ngx_str_t priority;
|
||||
+
|
||||
+ name = priority = (ngx_str_t) ngx_null_string;
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
if (clcf->error_log) {
|
||||
return "is duplicate";
|
||||
}
|
||||
@@ -4910,6 +4922,36 @@ ngx_http_core_error_log(ngx_conf_t *cf,
|
||||
if (ngx_strcmp(value[1].data, "stderr") == 0) {
|
||||
ngx_str_null(&name);
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ } else if (ngx_strncmp(value[1].data, "syslog", sizeof("syslog") - 1) == 0) {
|
||||
+ if (!cf->cycle->new_log.syslog_set) {
|
||||
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
+ "You must set the syslog directive and enable it first.");
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ syslog_on = 1;
|
||||
+
|
||||
+ if (value[1].data[sizeof("syslog") - 1] == ':') {
|
||||
+ priority.len = value[1].len - sizeof("syslog");
|
||||
+ priority.data = value[1].data + sizeof("syslog");
|
||||
+
|
||||
+ off = (u_char*) ngx_strchr(priority.data, '|');
|
||||
+ if (off != NULL) {
|
||||
+ priority.len = off - priority.data;
|
||||
+
|
||||
+ off++;
|
||||
+ name.len = value[1].data + value[1].len - off;
|
||||
+ name.data = off;
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ if (value[1].len > sizeof("syslog")) {
|
||||
+ name.len = value[1].len - sizeof("syslog");
|
||||
+ name.data = value[1].data + sizeof("syslog");
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
} else {
|
||||
name = value[1];
|
||||
}
|
||||
@@ -4919,6 +4961,17 @@ ngx_http_core_error_log(ngx_conf_t *cf,
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ if (syslog_on) {
|
||||
+ clcf->error_log->syslog_on = 1;
|
||||
+ if (ngx_log_set_priority(cf, &priority, clcf->error_log) == NGX_CONF_ERROR) {
|
||||
+ return NGX_CONF_ERROR;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ clcf->error_log->log_level = 0;
|
||||
+#endif
|
||||
+
|
||||
if (cf->args->nelts == 2) {
|
||||
clcf->error_log->log_level = NGX_LOG_ERR;
|
||||
return NGX_CONF_OK;
|
||||
Index: nginx-1.4.7/src/http/ngx_http_request.c
|
||||
===================================================================
|
||||
--- nginx-1.4.7.orig/src/http/ngx_http_request.c
|
||||
+++ nginx-1.4.7/src/http/ngx_http_request.c
|
||||
@@ -533,6 +533,9 @@ ngx_http_create_request(ngx_connection_t
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
ngx_http_set_connection_log(r->connection, clcf->error_log);
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ c->log->priority = clcf->error_log->priority;
|
||||
+#endif
|
||||
|
||||
r->header_in = hc->nbusy ? hc->busy[0] : c->buffer;
|
||||
|
||||
@@ -872,6 +875,9 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *
|
||||
clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
|
||||
|
||||
ngx_http_set_connection_log(c, clcf->error_log);
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ c->log->priority = clcf->error_log->priority;
|
||||
+#endif
|
||||
|
||||
sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module);
|
||||
|
||||
@@ -2077,6 +2083,9 @@ ngx_http_set_virtual_server(ngx_http_req
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
ngx_http_set_connection_log(r->connection, clcf->error_log);
|
||||
+#if (NGX_ENABLE_SYSLOG)
|
||||
+ r->connection->log->priority = clcf->error_log->priority;
|
||||
+#endif
|
||||
|
||||
return NGX_OK;
|
||||
}
|
Loading…
Reference in a new issue