You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

365 lines
11 KiB

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