ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/net/nginx/Config_ssl.in b/external/subpack/net/nginx/Config_ssl.in
new file mode 100644
index 0000000..1c53dab
--- /dev/null
+++ b/external/subpack/net/nginx/Config_ssl.in
@@ -0,0 +1,262 @@
+#
+# Copyright (C) 2010-2016 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-ssl
+
+config NGINX_DAV
+	bool
+	prompt "Enable WebDAV module"
+	help
+		Enable the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and MOVE.
+	default n
+
+config NGINX_UBUS
+	bool
+	prompt "Enable UBUS module"
+	help
+		Enable UBUS api support directly from the server.
+	default y
+
+config NGINX_FLV
+	bool
+	prompt "Enable FLV module"
+	help
+		Provides the ability to seek within FLV (Flash) files using time-based offsets.
+	default n
+
+config NGINX_STUB_STATUS
+	bool
+	prompt "Enable stub status module"
+	help
+		Enable the stub status module which gives some status from the server.
+	default n
+
+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_AUTH_REQUEST
+	bool
+	prompt "Enable HTTP auth request module"
+	default n
+
+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_HASH
+	bool
+	prompt "Enable HTTP hash module"
+	default y
+
+config NGINX_HTTP_UPSTREAM_IP_HASH
+	bool
+	prompt "Enable HTTP IP hash module"
+	default y
+
+config NGINX_HTTP_UPSTREAM_LEAST_CONN
+	bool
+	prompt "Enable HTTP least conn module"
+	default y
+
+config NGINX_HTTP_UPSTREAM_KEEPALIVE
+	bool
+	prompt "Enable HTTP keepalive module"
+	default y
+
+config NGINX_HTTP_CACHE
+	bool
+	prompt "Enable HTTP cache"
+	default y
+
+config NGINX_HTTP_V2
+	bool
+	prompt "Enable HTTP_V2 module"
+	default y
+
+config NGINX_PCRE
+	bool
+	prompt "Enable PCRE library usage"
+	default y
+
+config NGINX_NAXSI
+	bool
+	prompt "Enable NAXSI module"
+	default y
+
+config NGINX_LUA
+	bool
+	prompt "Enable Lua module"
+	default n
+
+config NGINX_HTTP_REAL_IP
+	bool
+	prompt "Enable HTTP real ip module"
+	default n
+
+config NGINX_HTTP_SECURE_LINK
+	bool
+	prompt "Enable HTTP secure link module"
+	default n
+
+config NGINX_HTTP_SUB
+	bool
+	prompt "Enable HTTP sub module"
+	default n
+	
+config NGINX_HEADERS_MORE
+	bool
+	prompt "Enable Headers_more module"
+	help
+		Set and clear input and output headers...more than "add"!
+	default y
+	
+config NGINX_HTTP_BROTLI
+	bool
+	prompt "Enable Brotli compression module"
+	help
+		Add support for brotli compression module.
+	default n
+
+config NGINX_STREAM_CORE_MODULE
+	bool
+	prompt "Enable stream support"
+	help
+		Add support for NGINX request streaming.
+	default n
+
+config NGINX_STREAM_SSL_MODULE
+	bool
+	prompt "Enable stream support with SSL/TLS termination"
+	depends on NGINX_STREAM_CORE_MODULE
+	help
+		Add support for NGINX request streaming with SSL/TLS termination.
+	default n
+
+config NGINX_STREAM_SSL_PREREAD_MODULE
+	bool
+	prompt "Enable stream support with SSL/TLS pre-read"
+	depends on NGINX_STREAM_CORE_MODULE
+	help
+		Add support for NGINX request streaming using information from the ClientHello message without terminating SSL/TLS.
+	default n
+
+config NGINX_RTMP_MODULE
+	bool
+	prompt "Enable RTMP module"
+	help
+		Add support for NGINX-based Media Streaming Server module.
+		DASH enhanced - https://github.com/ut0mt8/nginx-rtmp-module
+	default n
+
+config NGINX_TS_MODULE
+	bool
+	prompt "Enable TS module"
+	help
+		Add support for MPEG-TS Live Module module.
+	default n
+
+endmenu
diff --git a/external/subpack/net/nginx/Makefile b/external/subpack/net/nginx/Makefile
new file mode 100644
index 0000000..7105e6c
--- /dev/null
+++ b/external/subpack/net/nginx/Makefile
@@ -0,0 +1,577 @@
+#
+# Copyright (C) 2012-2016 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.19.6
+PKG_RELEASE:=2
+
+PKG_SOURCE:=nginx-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://nginx.org/download/
+PKG_HASH:=b11195a02b1d3285ddf2987e02c6b6d28df41bb1b1dd25f33542848ef4fc33b5
+
+PKG_MAINTAINER:=Thomas Heil <heil@terminal-consulting.de> \
+				Ansuel Smith <ansuelsmth@gmail.com>
+PKG_LICENSE:=2-clause BSD-like license
+PKG_CPE_ID:=cpe:/a:nginx:nginx
+
+PKG_FIXUP:=autoreconf
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+PKG_CONFIG_DEPENDS := \
+	CONFIG_NGINX_DAV \
+	CONFIG_NGINX_FLV \
+	CONFIG_NGINX_UBUS \
+	CONFIG_NGINX_STUB_STATUS \
+	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_AUTH_REQUEST \
+	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_HASH \
+	CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH \
+	CONFIG_NGINX_HTTP_UPSTREAM_LEAST_CONN \
+	CONFIG_NGINX_HTTP_UPSTREAM_KEEPALIVE \
+	CONFIG_NGINX_HTTP_UPSTREAM_ZONE \
+	CONFIG_NGINX_HTTP_CACHE \
+	CONFIG_NGINX_HTTP_V2 \
+	CONFIG_NGINX_PCRE \
+	CONFIG_NGINX_NAXSI \
+	CONFIG_NGINX_LUA \
+	CONFIG_NGINX_HTTP_REAL_IP \
+	CONFIG_NGINX_HTTP_SECURE_LINK \
+	CONFIG_NGINX_HTTP_BROTLI \
+	CONFIG_NGINX_HEADERS_MORE \
+	CONFIG_NGINX_STREAM_CORE_MODULE \
+	CONFIG_NGINX_STREAM_SSL_MODULE \
+	CONFIG_NGINX_STREAM_SSL_PREREAD_MODULE \
+	CONFIG_NGINX_RTMP_MODULE \
+	CONFIG_NGINX_TS_MODULE \
+	CONFIG_OPENSSL_ENGINE \
+	CONFIG_OPENSSL_WITH_NPN
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/nginx/default
+  SECTION:=net
+  CATEGORY:=Network
+  SUBMENU:=Web Servers/Proxies
+  TITLE:=Nginx web server
+  URL:=http://nginx.org/
+  DEPENDS:=+libopenssl +libpthread
+  # TODO: add PROVIDES when removing nginx
+  # PROVIDES:=nginx
+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-ssl
+  $(Package/nginx/default)
+  TITLE += with SSL support
+  VARIANT:=ssl
+  DEPENDS+= +NGINX_PCRE:libpcre \
+	+NGINX_PCRE:nginx-ssl-util +!NGINX_PCRE:nginx-ssl-util-nopcre \
+	+NGINX_HTTP_GZIP:zlib +NGINX_LUA:liblua +NGINX_DAV:libxml2 \
+	+NGINX_UBUS:libubus +NGINX_UBUS:libblobmsg-json +NGINX_UBUS:libjson-c
+  EXTRA_DEPENDS:=nginx-ssl-util$(if $(CONFIG_NGINX_PCRE),,-nopcre) (>=1.5-1) (<2)
+  CONFLICTS:=nginx-all-module
+endef
+
+Package/nginx-ssl/description = $(Package/nginx/description) \
+  This variant is compiled with SSL support enabled. To enable additional module \
+  select them in the nginx default configuration menu.
+
+define Package/nginx-all-module
+  $(Package/nginx/default)
+  TITLE += with ALL module selected
+  DEPENDS+=+libpcre +nginx-ssl-util +zlib +liblua +libxml2 +libubus \
+	+libblobmsg-json +libjson-c
+  EXTRA_DEPENDS:=nginx-ssl-util (>=1.5-1) (<2)
+  VARIANT:=all-module
+  PROVIDES += nginx-ssl
+endef
+
+Package/nginx-all-module/description = $(Package/nginx/description) \
+  This variant is compiled with ALL module selected.
+
+define Package/nginx-ssl/config
+  source "$(SOURCE)/Config_ssl.in"
+endef
+
+config_files=mime.types
+
+define Package/nginx/conffiles
+/etc/nginx/
+endef
+
+Package/nginx-ssl/conffiles = $(Package/nginx/conffiles)
+Package/nginx-all-module/conffiles = $(Package/nginx/conffiles)
+
+
+ADDITIONAL_MODULES:= --with-http_ssl_module
+
+ifneq ($(BUILD_VARIANT),all-module)
+  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
+  else
+    config_files += koi-utf koi-win win-utf
+  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
+  else
+    config_files += fastcgi_params
+  endif
+  ifneq ($(CONFIG_NGINX_HTTP_UWSGI),y)
+    ADDITIONAL_MODULES += --without-http_uwsgi_module
+  else
+    config_files += uwsgi_params
+  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_HASH),y)
+    ADDITIONAL_MODULES += --without-http_upstream_hash_module
+  endif
+  ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH),y)
+    ADDITIONAL_MODULES += --without-http_upstream_ip_hash_module
+  endif
+  ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_LEAST_CONN),y)
+    ADDITIONAL_MODULES += --without-http_upstream_least_conn_module
+  endif
+  ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_KEEPALIVE),y)
+    ADDITIONAL_MODULES += --without-http_upstream_keepalive_module
+  endif
+  ifeq ($(CONFIG_NGINX_NAXSI),y)
+    ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src
+  endif
+  ifeq ($(CONFIG_NGINX_LUA),y)
+    ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/lua-nginx
+  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_DAV),y)
+    ADDITIONAL_MODULES += --with-http_dav_module --add-module=$(PKG_BUILD_DIR)/nginx-dav-ext-module
+  endif
+  ifeq ($(CONFIG_NGINX_UBUS),y)
+    ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-ubus-module
+  endif
+  ifeq ($(CONFIG_NGINX_HTTP_AUTH_REQUEST),y)
+    ADDITIONAL_MODULES += --with-http_auth_request_module
+  endif
+  ifeq ($(CONFIG_NGINX_HTTP_V2),y)
+    ADDITIONAL_MODULES += --with-http_v2_module
+  endif
+  ifeq ($(CONFIG_NGINX_HTTP_REAL_IP),y)
+    ADDITIONAL_MODULES += --with-http_realip_module
+  endif
+  ifeq ($(CONFIG_NGINX_HTTP_SECURE_LINK),y)
+    ADDITIONAL_MODULES += --with-http_secure_link_module
+  endif
+  ifeq ($(CONFIG_NGINX_HTTP_SUB),y)
+	ADDITIONAL_MODULES += --with-http_sub_module
+  endif
+  ifeq ($(CONFIG_NGINX_STREAM_CORE_MODULE),y)
+    ADDITIONAL_MODULES += --with-stream
+  endif
+  ifeq ($(CONFIG_NGINX_STREAM_SSL_MODULE),y)
+    ADDITIONAL_MODULES += --with-stream_ssl_module
+  endif
+  ifeq ($(CONFIG_NGINX_STREAM_SSL_PREREAD_MODULE),y)
+    ADDITIONAL_MODULES += --with-stream_ssl_preread_module
+  endif
+  ifeq ($(CONFIG_NGINX_HEADERS_MORE),y)
+    ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-headers-more
+  endif
+  ifeq ($(CONFIG_NGINX_HTTP_BROTLI),y)
+    ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-brotli
+  endif
+  ifeq ($(CONFIG_NGINX_RTMP_MODULE),y)
+    ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-rtmp
+  endif
+  ifeq ($(CONFIG_NGINX_TS_MODULE),y)
+    ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-ts
+  endif
+else
+  CONFIG_NGINX_HEADERS_MORE:=y
+  CONFIG_NGINX_HTTP_BROTLI:=y
+  CONFIG_NGINX_RTMP_MODULE:=y
+  CONFIG_NGINX_TS_MODULE:=y
+  CONFIG_NGINX_NAXSI:=y
+  CONFIG_NGINX_LUA:=y
+  CONFIG_NGINX_DAV:=y
+  CONFIG_NGINX_UBUS:=y
+  ADDITIONAL_MODULES += --with-ipv6 --with-http_stub_status_module --with-http_flv_module \
+	--with-http_dav_module \
+	--with-http_auth_request_module --with-http_v2_module --with-http_realip_module \
+	--with-http_secure_link_module --with-http_sub_module \
+	--with-stream --with-stream_ssl_module --with-stream_ssl_preread_module \
+	--add-module=$(PKG_BUILD_DIR)/nginx-headers-more \
+	--add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src \
+	--add-module=$(PKG_BUILD_DIR)/lua-nginx \
+	--add-module=$(PKG_BUILD_DIR)/nginx-dav-ext-module \
+	--add-module=$(PKG_BUILD_DIR)/nginx-brotli --add-module=$(PKG_BUILD_DIR)/nginx-rtmp \
+	--add-module=$(PKG_BUILD_DIR)/nginx-ts --add-module=$(PKG_BUILD_DIR)/nginx-ubus-module
+  config_files += koi-utf koi-win win-utf fastcgi_params uwsgi_params
+endif
+
+define Package/nginx-mod-luci
+  TITLE:=Nginx on LuCI
+  SECTION:=net
+  CATEGORY:=Network
+  SUBMENU:=Web Servers/Proxies
+  TITLE:=Support file for Nginx
+  URL:=http://nginx.org/
+  DEPENDS:=+uwsgi +uwsgi-luci-support +nginx
+  # TODO: add PROVIDES when removing nginx-mod-luci-ssl
+  # PROVIDES:=nginx-mod-luci-ssl
+endef
+
+define Package/nginx-mod-luci/description
+ Support file for LuCI in nginx. Include custom nginx configuration, autostart script for uwsgi.
+endef
+
+
+TARGET_CFLAGS += -fvisibility=hidden -ffunction-sections -fdata-sections -DNGX_LUA_NO_BY_LUA_BLOCK
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+ifeq ($(CONFIG_NGINX_LUA),y)
+  CONFIGURE_VARS += LUA_INC=$(STAGING_DIR)/usr/include \
+					LUA_LIB=$(STAGING_DIR)/usr/lib
+endif
+
+CONFIGURE_VARS += CONFIG_BIG_ENDIAN=$(CONFIG_BIG_ENDIAN)
+
+CONFIGURE_ARGS += \
+			--crossbuild=Linux::$(ARCH) \
+			--prefix=/usr \
+			--conf-path=/etc/nginx/nginx.conf \
+			$(ADDITIONAL_MODULES) \
+			--error-log-path=stderr \
+			--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)" \
+			--without-http_upstream_zone_module
+
+define Package/nginx-mod-luci/install
+	$(INSTALL_DIR) $(1)/etc/nginx/conf.d
+	$(INSTALL_CONF) ./files-luci-support/luci.locations $(1)/etc/nginx/conf.d/
+	$(INSTALL_DIR) $(1)/etc/uci-defaults
+	$(INSTALL_BIN) ./files-luci-support/60_nginx-luci-support $(1)/etc/uci-defaults/60_nginx-luci-support
+endef
+
+define Package/nginx-ssl/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/
+	$(INSTALL_DIR) $(1)/etc/nginx/conf.d
+	$(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
+ifeq ($(CONFIG_NGINX_NAXSI),y)
+	$(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
+endif
+	$(if $(CONFIG_NGINX_NAXSI),$($(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx))
+	$(if $(CONFIG_NGINX_NAXSI),$(chmod 0640 $(1)/etc/nginx/naxsi_core.rules))
+endef
+
+Package/nginx-all-module/install = $(Package/nginx-ssl/install)
+
+define Package/nginx-ssl/prerm
+#!/bin/sh
+[ -z "$${IPKG_INSTROOT}" ] || exit 0
+[ "$${PKG_UPGRADE}" = "1" ] && exit 0
+eval $$(/usr/bin/nginx-util get_env)
+[ "$$(uci get "nginx.$${LAN_NAME}.$${MANAGE_SSL}")" = "self-signed" ] || exit 0
+rm -f "$$(uci get "nginx.$${LAN_NAME}.ssl_certificate")"
+rm -f "$$(uci get "nginx.$${LAN_NAME}.ssl_certificate_key")"
+exit 0
+endef
+
+Package/nginx-all-module/prerm = $(Package/nginx-ssl/prerm)
+
+define Build/Prepare
+	$(Build/Prepare/Default)
+	$(Prepare/nginx-naxsi)
+	$(Prepare/lua-nginx)
+	$(Prepare/nginx-brotli)
+	$(Prepare/nginx-headers-more)
+	$(Prepare/nginx-rtmp)
+	$(Prepare/nginx-ts)
+	$(Prepare/nginx-dav-ext-module)
+	$(Prepare/nginx-ubus-module)
+endef
+
+
+ifeq ($(CONFIG_NGINX_HEADERS_MORE),y)
+  define Download/nginx-headers-more
+    VERSION:=a9f7c7e86cc7441d04e2f11f01c2e3a9c4b0301d
+    SUBDIR:=nginx-headers-more
+    FILE:=headers-more-nginx-module-$$(VERSION).tar.xz
+    URL:=https://github.com/openresty/headers-more-nginx-module.git
+    MIRROR_HASH:=ce0b9996ecb2cff790831644d6ab1adc087aa2771d77d3931c06246d11bc59fd
+    PROTO:=git
+  endef
+  $(eval $(call Download,nginx-headers-more))
+
+  define Prepare/nginx-headers-more
+	$(eval $(Download/nginx-headers-more))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+  endef
+endif
+
+
+ifeq ($(CONFIG_NGINX_HTTP_BROTLI),y)
+  define Download/nginx-brotli
+    VERSION:=e505dce68acc190cc5a1e780a3b0275e39f160ca
+    SUBDIR:=nginx-brotli
+    FILE:=ngx-brotli-module-$$(VERSION).tar.xz
+    URL:=https://github.com/google/ngx_brotli.git
+    MIRROR_HASH:=04847f11ef808fed50f44b2af0ef3abf59ff0ffc06dfc7394d9ab51d53fef31f
+    PROTO:=git
+  endef
+  $(eval $(call Download,nginx-brotli))
+
+  define Prepare/nginx-brotli
+	$(eval $(Download/nginx-brotli))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+  endef
+endif
+
+
+ifeq ($(CONFIG_NGINX_RTMP_MODULE),y)
+  define Download/nginx-rtmp
+    VERSION:=f0ea62342a4eca504b311cd5df910d026c3ea4cf
+    SUBDIR:=nginx-rtmp
+    FILE:=ngx-rtmp-module-$$(VERSION).tar.xz
+    URL:=https://github.com/ut0mt8/nginx-rtmp-module.git
+    MIRROR_HASH:=d3f58066f0f858ed79f7f2b0c9b89de2ccc512c94ab3d0625f6dcff3df0b72c1
+    PROTO:=git
+  endef
+  $(eval $(call Download,nginx-rtmp))
+
+  define  Prepare/nginx-rtmp
+	$(eval $(Download/nginx-rtmp))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+  endef
+endif
+
+
+ifeq ($(CONFIG_NGINX_TS_MODULE),y)
+  define Download/nginx-ts
+    VERSION:=ef2f874d95cc75747eb625a292524a702aefb0fd
+    SUBDIR:=nginx-ts
+    FILE:=ngx-ts-module-$$(VERSION).tar.xz
+    URL:=https://github.com/arut/nginx-ts-module.git
+    MIRROR_HASH:=73938950bb286d40d9e54b0994d1a63827340c1156c72eb04d7041b25b20ec18
+    PROTO:=git
+  endef
+  $(eval $(call Download,nginx-ts))
+
+  define  Prepare/nginx-ts
+	$(eval $(Download/nginx-ts))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+  endef
+endif
+
+
+ifeq ($(CONFIG_NGINX_NAXSI),y)
+  define Download/nginx-naxsi
+    VERSION:=951123ad456bdf5ac94e8d8819342fe3d49bc002
+    SUBDIR:=nginx-naxsi
+    FILE:=nginx-naxsi-module-$$(VERSION).tar.xz
+    URL:=https://github.com/nbs-system/naxsi.git
+    MIRROR_HASH:=c734cae19a596affadd62a2df1b58d3df8d1364093a4e80a7cd1ab4555963535
+    PROTO:=git
+  endef
+  $(eval $(call Download,nginx-naxsi))
+
+  define Prepare/nginx-naxsi
+	$(eval $(Download/nginx-naxsi))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+  endef
+endif
+
+
+ifeq ($(CONFIG_NGINX_LUA),y)
+  define Download/lua-nginx
+    VERSION:=e94f2e5d64daa45ff396e262d8dab8e56f5f10e0
+    SUBDIR:=lua-nginx
+    FILE:=lua-nginx-module-$$(VERSION).tar.xz
+    URL:=https://github.com/openresty/lua-nginx-module.git
+    MIRROR_HASH:=27729921964f066d97e99c263da153b34622a2f4b811114e4c3ee61c6fc71395
+    PROTO:=git
+  endef
+  $(eval $(call Download,lua-nginx))
+
+  define Prepare/lua-nginx
+	$(eval $(Download/lua-nginx))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+	$(call PatchDir,$(PKG_BUILD_DIR),./patches-lua-nginx)
+  endef
+endif
+
+
+ifeq ($(CONFIG_NGINX_DAV),y)
+  define Download/nginx-dav-ext-module
+    VERSION:=f5e30888a256136d9c550bf1ada77d6ea78a48af
+    SUBDIR:=nginx-dav-ext-module
+    FILE:=nginx-dav-ext-module-$$(VERSION).tar.xz
+    URL:=https://github.com/arut/nginx-dav-ext-module.git
+    MIRROR_HASH:=70bb4c3907f4b783605500ba494e907aede11f8505702e370012abb3c177dc5b
+    PROTO:=git
+  endef
+  $(eval $(call Download,nginx-dav-ext-module))
+
+  define Prepare/nginx-dav-ext-module
+	$(eval $(Download/nginx-dav-ext-module))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+	$(call PatchDir,$(PKG_BUILD_DIR),./patches-dav-nginx)
+  endef
+endif
+
+ifeq ($(CONFIG_NGINX_UBUS),y)
+  define Download/nginx-ubus-module
+    VERSION:=b2d7260dcb428b2fb65540edb28d7538602b4a26
+    SUBDIR:=nginx-ubus-module
+    FILE:=nginx-ubus-module-$$(VERSION).tar.xz
+    URL:=https://github.com/Ansuel/nginx-ubus-module.git
+    MIRROR_HASH:=472cef416d25effcac66c85417ab6596e634a7a64d45b709bb090892d567553c
+    PROTO:=git
+  endef
+  $(eval $(call Download,nginx-ubus-module))
+
+  define Prepare/nginx-ubus-module
+	$(eval $(Download/nginx-ubus-module))
+	xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
+  endef
+endif
+
+$(eval $(call BuildPackage,nginx-ssl))
+$(eval $(call BuildPackage,nginx-all-module))
+$(eval $(call BuildPackage,nginx-mod-luci))
+
+# TODO: remove after a transition period (together with pkg nginx-util):
+# It is for smoothly substituting nginx and nginx-mod-luci-ssl (by nginx-ssl
+# respectively nginx-mod-luci). Add above commented PROVIDES when removing.
+
+define Package/nginx
+  TITLE:=Dummy package for transition when upgrading.
+  DEPENDS:=+nginx-ssl
+  PKGARCH:=all
+endef
+
+define Package/nginx/install
+	$(INSTALL_DIR) $(1)/usr/bin
+endef
+
+$(eval $(call BuildPackage,nginx))
+
+define Package/nginx-mod-luci-ssl
+  TITLE:=Dummy package for transition when upgrading.
+  DEPENDS:=+nginx-mod-luci
+  PKGARCH:=all
+endef
+
+define Package/nginx-mod-luci-ssl/install
+	$(INSTALL_DIR) $(1)/usr/bin
+endef
+
+$(eval $(call BuildPackage,nginx-mod-luci-ssl))
diff --git a/external/subpack/net/nginx/files-luci-support/60_nginx-luci-support b/external/subpack/net/nginx/files-luci-support/60_nginx-luci-support
new file mode 100644
index 0000000..b256444
--- /dev/null
+++ b/external/subpack/net/nginx/files-luci-support/60_nginx-luci-support
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+if nginx -V 2>&1 | grep -q ubus; then
+	if [ -z "$(cat /etc/nginx/conf.d/luci.locations | grep ubus)" ]; then
+		cat <<EOT >> /etc/nginx/conf.d/luci.locations
+
+location /ubus {
+        ubus_interpreter;
+        ubus_socket_path /var/run/ubus/ubus.sock;
+        ubus_parallel_req 2;
+}
+EOT
+	fi
+fi
+
+grep -q /var/run/ubus.sock /etc/nginx/conf.d/luci.locations &&
+	sed -i 's#/var/run/ubus.sock#/var/run/ubus/ubus.sock#' /etc/nginx/conf.d/luci.locations
+
+if [ -x /etc/init.d/uhttpd ]; then
+        /etc/init.d/uhttpd disable
+        if [ -n "$(pgrep uhttpd)" ]; then
+                /etc/init.d/uhttpd stop
+        fi
+fi
+
+/etc/init.d/nginx enable
+if [ -n "$(pgrep nginx)" ]; then
+        /etc/init.d/nginx restart
+else
+        /etc/init.d/nginx start
+fi
+
+/etc/init.d/uwsgi enable
+if [ -n "$(pgrep uwsgi)" ]; then
+        /etc/init.d/uwsgi restart
+else
+        /etc/init.d/uwsgi start
+fi
+
+
+exit 0
diff --git a/external/subpack/net/nginx/files-luci-support/luci.locations b/external/subpack/net/nginx/files-luci-support/luci.locations
new file mode 100644
index 0000000..374ee5d
--- /dev/null
+++ b/external/subpack/net/nginx/files-luci-support/luci.locations
@@ -0,0 +1,17 @@
+location /cgi-bin/luci {
+		index  index.html;
+		include uwsgi_params;
+		uwsgi_param SERVER_ADDR $server_addr;
+		uwsgi_modifier1 9;
+		uwsgi_pass unix:////var/run/luci-webui.socket;
+}
+location ~ /cgi-bin/cgi-(backup|download|upload|exec) {
+		include uwsgi_params;
+		uwsgi_param SERVER_ADDR $server_addr;
+		uwsgi_modifier1 9;
+		uwsgi_pass unix:////var/run/luci-cgi_io.socket;
+}
+
+location /luci-static {
+		error_log stderr crit;
+}
diff --git a/external/subpack/net/nginx/files/nginx.init b/external/subpack/net/nginx/files/nginx.init
new file mode 100644
index 0000000..300a8c6
--- /dev/null
+++ b/external/subpack/net/nginx/files/nginx.init
@@ -0,0 +1,73 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2015 OpenWrt.org
+
+START=80
+
+USE_PROCD=1
+
+G_OPTS="daemon off;"
+
+NGINX_UTIL="/usr/bin/nginx-util"
+
+eval $("${NGINX_UTIL}" get_env)
+
+CONF=""
+
+
+nginx_init() {
+	[ -z "${CONF}" ] || return # already called.
+
+	[ -d /var/log/nginx ] || mkdir -p /var/log/nginx
+	[ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx
+
+	rm -f "$(readlink "${UCI_CONF}")"
+	${NGINX_UTIL} init_lan
+
+	if [ -e "${UCI_CONF}" ]
+	then CONF="${UCI_CONF}"
+	else CONF="${NGINX_CONF}"
+	fi
+
+	local message
+	message="$(/usr/sbin/nginx -t -c "${CONF}" -g "${G_OPTS}" 2>&1)" ||
+	{
+		echo -e "${message}" | logger -t "nginx_init" -p "daemon.err"
+		logger -s -t "nginx_init" -p "daemon.err" "NOT using conf file!"
+		echo "show config to be used by: nginx -T -c '${CONF}'" >&2
+		exit 1
+	}
+
+	logger -t "nginx_init" -p "daemon.info" "using ${CONF} (the test is ok)"
+}
+
+
+start_service() {
+	nginx_init
+
+	procd_open_instance
+	procd_set_param command /usr/sbin/nginx -c "${CONF}" -g "${G_OPTS}"
+	procd_set_param stdout 1
+	procd_set_param stderr 1
+	procd_set_param file "${CONF}" "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \
+		"${CONF_DIR}*.conf" "${CONF_DIR}*.locations"
+	procd_set_param respawn
+	procd_close_instance
+}
+
+
+reload_service() {
+	nginx_init
+
+	if [ "$(cat "/proc/$(cat "/var/run/nginx.pid")/cmdline")" = \
+	     "nginx: master process /usr/sbin/nginx -c ${CONF} -g ${G_OPTS}" ]
+	then procd_send_signal nginx
+	else restart
+	fi
+}
+
+
+extra_command "relog" "Reopen log files (without reloading)"
+relog() {
+	[ -d /var/log/nginx ] || mkdir -p /var/log/nginx
+	procd_send_signal nginx '*' USR1
+}
diff --git a/external/subpack/net/nginx/patches-dav-nginx/100-drop-libxslt-dep.patch b/external/subpack/net/nginx/patches-dav-nginx/100-drop-libxslt-dep.patch
new file mode 100644
index 0000000..c5941f4
--- /dev/null
+++ b/external/subpack/net/nginx/patches-dav-nginx/100-drop-libxslt-dep.patch
@@ -0,0 +1,14 @@
+--- a/nginx-dav-ext-module/config	2018-12-17 08:45:12.000000000 +0000
++++ b/nginx-dav-ext-module/config	2019-10-11 13:49:41.446919258 +0000
+@@ -8,9 +8,8 @@ ngx_module_name=ngx_http_dav_ext_module
+ # building nginx with the xslt module, in which case libxslt will
+ # be linked anyway.  In other cases libxslt is just redundant.
+ # If that's a big deal, libxml2 can be linked directly:
+-# ngx_module_libs=-lxml2
++ngx_module_libs=-lxml2
++ngx_module_incs=$(pkg-config --cflags-only-I libxml-2.0 | sed 's/^-I//')
+ 
+-ngx_module_libs=LIBXSLT
+-
+ ngx_module_srcs="$ngx_addon_dir/ngx_http_dav_ext_module.c"
+ 
diff --git a/external/subpack/net/nginx/patches-lua-nginx/100-no_by_lua_block.patch b/external/subpack/net/nginx/patches-lua-nginx/100-no_by_lua_block.patch
new file mode 100644
index 0000000..968e12d
--- /dev/null
+++ b/external/subpack/net/nginx/patches-lua-nginx/100-no_by_lua_block.patch
@@ -0,0 +1,195 @@
+--- a/lua-nginx/src/ngx_http_lua_module.c
++++ b/lua-nginx/src/ngx_http_lua_module.c
+@@ -165,14 +165,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       offsetof(ngx_http_lua_loc_conf_t, log_socket_errors),
+       NULL },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("init_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_init_by_lua_block,
+       NGX_HTTP_MAIN_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_init_by_inline },
+-
++#endif
+     { ngx_string("init_by_lua"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+       ngx_http_lua_init_by_lua,
+@@ -186,14 +186,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_MAIN_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_init_by_file },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("init_worker_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_init_worker_by_lua_block,
+       NGX_HTTP_MAIN_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_init_worker_by_inline },
+-
++#endif
+     { ngx_string("init_worker_by_lua"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+       ngx_http_lua_init_worker_by_lua,
+@@ -209,6 +209,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       (void *) ngx_http_lua_init_worker_by_file },
+ 
+ #if defined(NDK) && NDK
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* set_by_lua $res { inline Lua code } [$arg1 [$arg2 [...]]] */
+     { ngx_string("set_by_lua_block"),
+       NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -217,7 +218,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_filter_set_by_lua_inline },
+-
++#endif
+     /* set_by_lua $res <inline script> [$arg1 [$arg2 [...]]] */
+     { ngx_string("set_by_lua"),
+       NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -245,7 +246,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_rewrite_handler_inline },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* rewrite_by_lua_block { <inline script> } */
+     { ngx_string("rewrite_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -254,7 +255,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_rewrite_handler_inline },
+-
++#endif
+     /* access_by_lua "<inline script>" */
+     { ngx_string("access_by_lua"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -263,7 +264,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_access_handler_inline },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* access_by_lua_block { <inline script> } */
+     { ngx_string("access_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -272,7 +273,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_access_handler_inline },
+-
++#endif
+     /* content_by_lua "<inline script>" */
+     { ngx_string("content_by_lua"),
+       NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
+@@ -280,7 +281,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_content_handler_inline },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* content_by_lua_block { <inline script> } */
+     { ngx_string("content_by_lua_block"),
+       NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+@@ -288,7 +289,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_content_handler_inline },
+-
++#endif
+     /* log_by_lua <inline script> */
+     { ngx_string("log_by_lua"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -297,7 +298,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_log_handler_inline },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* log_by_lua_block { <inline script> } */
+     { ngx_string("log_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -306,7 +307,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_log_handler_inline },
+-
++#endif
+     { ngx_string("rewrite_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+                         |NGX_CONF_TAKE1,
+@@ -361,7 +362,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_header_filter_inline },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* header_filter_by_lua_block { <inline script> } */
+     { ngx_string("header_filter_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -370,7 +371,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_header_filter_inline },
+-
++#endif
+     { ngx_string("header_filter_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+                         |NGX_CONF_TAKE1,
+@@ -386,7 +387,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_body_filter_inline },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* body_filter_by_lua_block { <inline script> } */
+     { ngx_string("body_filter_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -395,7 +396,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_body_filter_inline },
+-
++#endif
+     { ngx_string("body_filter_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+                         |NGX_CONF_TAKE1,
+@@ -403,14 +404,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_body_filter_file },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("balancer_by_lua_block"),
+       NGX_HTTP_UPS_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_balancer_by_lua_block,
+       NGX_HTTP_SRV_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_balancer_handler_inline },
+-
++#endif
+     { ngx_string("balancer_by_lua_file"),
+       NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
+       ngx_http_lua_balancer_by_lua,
+@@ -517,14 +518,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       offsetof(ngx_http_lua_loc_conf_t, ssl_ciphers),
+       NULL },
+-
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("ssl_certificate_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_ssl_cert_by_lua_block,
+       NGX_HTTP_SRV_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_ssl_cert_handler_inline },
+-
++#endif
+     { ngx_string("ssl_certificate_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+       ngx_http_lua_ssl_cert_by_lua,
diff --git a/external/subpack/net/nginx/patches/101-feature_test_fix.patch b/external/subpack/net/nginx/patches/101-feature_test_fix.patch
new file mode 100644
index 0000000..b867c88
--- /dev/null
+++ b/external/subpack/net/nginx/patches/101-feature_test_fix.patch
@@ -0,0 +1,116 @@
+--- 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
+@@ -183,7 +183,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
+     else
+         ngx_feature="gcc builtin atomic operations"
+         ngx_feature_name=NGX_HAVE_GCC_ATOMIC
+-        ngx_feature_run=yes
++        ngx_feature_run=no
+         ngx_feature_incs=
+         ngx_feature_path=
+         ngx_feature_libs=
+@@ -204,7 +204,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=
+@@ -218,7 +218,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
+@@ -36,7 +36,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=
+@@ -110,7 +110,7 @@ ngx_feature_test="int fd; struct stat sb
+ 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=
+@@ -131,7 +131,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=
+@@ -149,7 +149,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
+@@ -840,7 +840,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=
+@@ -853,7 +853,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>"
+@@ -868,7 +868,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=
+@@ -882,7 +882,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=
diff --git a/external/subpack/net/nginx/patches/102-sizeof_test_fix.patch b/external/subpack/net/nginx/patches/102-sizeof_test_fix.patch
new file mode 100644
index 0000000..7d2430e
--- /dev/null
+++ b/external/subpack/net/nginx/patches/102-sizeof_test_fix.patch
@@ -0,0 +1,27 @@
+--- a/auto/types/sizeof
++++ b/auto/types/sizeof
+@@ -25,8 +25,14 @@ $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(void) {
+-    printf("%d", (int) sizeof($ngx_type));
++    printf("dummy use of object_code_block to avoid gc-section: %c", object_code_block[0]);
+     return 0;
+ }
+ 
+@@ -40,7 +46,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
+ 
diff --git a/external/subpack/net/nginx/patches/103-sys_nerr.patch b/external/subpack/net/nginx/patches/103-sys_nerr.patch
new file mode 100644
index 0000000..5f5d106
--- /dev/null
+++ b/external/subpack/net/nginx/patches/103-sys_nerr.patch
@@ -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:
diff --git a/external/subpack/net/nginx/patches/104-endianness_fix.patch b/external/subpack/net/nginx/patches/104-endianness_fix.patch
new file mode 100644
index 0000000..4d8255e
--- /dev/null
+++ b/external/subpack/net/nginx/patches/104-endianness_fix.patch
@@ -0,0 +1,19 @@
+--- a/auto/endianness
++++ b/auto/endianness
+@@ -12,6 +12,16 @@ checking for system byte ordering
+ 
+ END
+ 
++if [ "${CONFIG_BIG_ENDIAN}" != "y" ]; then
++    echo " little endian"
++    have=NGX_HAVE_LITTLE_ENDIAN . auto/have
++else
++    echo " big endian"
++fi
++
++return
++
++
+ 
+ cat << END > $NGX_AUTOTEST.c
+ 
diff --git a/external/subpack/net/nginx/patches/200-config.patch b/external/subpack/net/nginx/patches/200-config.patch
new file mode 100644
index 0000000..f350095
--- /dev/null
+++ b/external/subpack/net/nginx/patches/200-config.patch
@@ -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" '
diff --git a/external/subpack/net/nginx/patches/201-ignore-invalid-options.patch b/external/subpack/net/nginx/patches/201-ignore-invalid-options.patch
new file mode 100644
index 0000000..d208bf5
--- /dev/null
+++ b/external/subpack/net/nginx/patches/201-ignore-invalid-options.patch
@@ -0,0 +1,12 @@
+--- a/auto/options
++++ b/auto/options
+@@ -400,8 +400,7 @@ $0: warning: the \"--with-sha1-asm\" opt
+         --test-build-solaris-sendfilev)  NGX_TEST_BUILD_SOLARIS_SENDFILEV=YES ;;
+ 
+         *)
+-            echo "$0: error: invalid option \"$option\""
+-            exit 1
++            echo "$0: error: ignoring invalid option \"$option\""
+         ;;
+     esac
+ done