Last active
July 23, 2018 00:53
-
-
Save myfreeer/bca792fdf42a826c765a25958dfae4dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Packages | |
*.gz | |
*.bz2 | |
*.xz | |
*.7z | |
*.tar | |
# Source folders | |
nginx/* | |
openssl-*/* | |
libressl-*/* | |
pcre-*/* | |
zlib-*/* | |
# Prerequisites | |
*.d | |
# Object files | |
*.o | |
*.ko | |
*.obj | |
*.elf | |
# Linker output | |
*.ilk | |
*.map | |
*.exp | |
# Precompiled Headers | |
*.gch | |
*.pch | |
# Libraries | |
*.lib | |
*.a | |
*.la | |
*.lo | |
# Shared objects (inc. Windows DLLs) | |
*.dll | |
*.so | |
*.so.* | |
*.dylib | |
# Executables | |
*.exe | |
*.out | |
*.app | |
*.i*86 | |
*.x86_64 | |
*.hex | |
# Debug files | |
*.dSYM/ | |
*.su | |
*.idb | |
*.pdb | |
# Kernel Module Compile Results | |
*.mod* | |
*.cmd | |
.tmp_versions/ | |
modules.order | |
Module.symvers | |
Mkfile.old | |
dkms.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b4325a4737837e20e1c11adf667bc8687ebbb11a Mon Sep 17 00:00:00 2001 | |
From: myfreeer <[email protected]> | |
Date: Fri, 20 Jul 2018 10:10:18 +0800 | |
Subject: [PATCH] autoindex: add escaping directive | |
Syntax: autoindex_escape_href on | off; | |
Default: autoindex_escape_href on; | |
Context: http, server, location | |
For the HTML format, specifies whether href attribute should be escaped. | |
--- | |
src/http/modules/ngx_http_autoindex_module.c | 25 +++++++++++++++----- | |
1 file changed, 19 insertions(+), 6 deletions(-) | |
diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c | |
index 94b91db..da7adae 100644 | |
--- a/src/http/modules/ngx_http_autoindex_module.c | |
+++ b/src/http/modules/ngx_http_autoindex_module.c | |
@@ -42,9 +42,9 @@ typedef struct { | |
ngx_uint_t format; | |
ngx_flag_t localtime; | |
ngx_flag_t exact_size; | |
+ ngx_flag_t escape_href; | |
} ngx_http_autoindex_loc_conf_t; | |
- | |
#define NGX_HTTP_AUTOINDEX_HTML 0 | |
#define NGX_HTTP_AUTOINDEX_JSON 1 | |
#define NGX_HTTP_AUTOINDEX_JSONP 2 | |
@@ -114,6 +114,13 @@ static ngx_command_t ngx_http_autoindex_commands[] = { | |
offsetof(ngx_http_autoindex_loc_conf_t, exact_size), | |
NULL }, | |
+ { ngx_string("autoindex_escape_href"), | |
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
+ ngx_conf_set_flag_slot, | |
+ NGX_HTTP_LOC_CONF_OFFSET, | |
+ offsetof(ngx_http_autoindex_loc_conf_t, escape_href), | |
+ NULL }, | |
+ | |
ngx_null_command | |
}; | |
@@ -485,12 +492,17 @@ ngx_http_autoindex_html(ngx_http_request_t *r, ngx_array_t *entries) | |
+ sizeof("</pre><hr>") - 1 | |
+ sizeof(tail) - 1; | |
+ alcf = ngx_http_get_module_loc_conf(r, ngx_http_autoindex_module); | |
+ | |
entry = entries->elts; | |
for (i = 0; i < entries->nelts; i++) { | |
- entry[i].escape = 2 * ngx_escape_uri(NULL, entry[i].name.data, | |
- entry[i].name.len, | |
- NGX_ESCAPE_URI_COMPONENT); | |
- | |
+ if (alcf->escape_href) { | |
+ entry[i].escape = 2 * ngx_escape_uri(NULL, entry[i].name.data, | |
+ entry[i].name.len, | |
+ NGX_ESCAPE_URI_COMPONENT); | |
+ } else { | |
+ entry[i].escape = 0; | |
+ } | |
entry[i].escape_html = ngx_escape_html(NULL, entry[i].name.data, | |
entry[i].name.len); | |
@@ -537,7 +549,6 @@ ngx_http_autoindex_html(ngx_http_request_t *r, ngx_array_t *entries) | |
b->last = ngx_cpymem(b->last, "<hr><pre><a href=\"../\">../</a>" CRLF, | |
sizeof("<hr><pre><a href=\"../\">../</a>" CRLF) - 1); | |
- alcf = ngx_http_get_module_loc_conf(r, ngx_http_autoindex_module); | |
tp = ngx_timeofday(); | |
for (i = 0; i < entries->nelts; i++) { | |
@@ -1016,6 +1027,7 @@ ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf) | |
conf->format = NGX_CONF_UNSET_UINT; | |
conf->localtime = NGX_CONF_UNSET; | |
conf->exact_size = NGX_CONF_UNSET; | |
+ conf->escape_href = NGX_CONF_UNSET; | |
return conf; | |
} | |
@@ -1032,6 +1044,7 @@ ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
NGX_HTTP_AUTOINDEX_HTML); | |
ngx_conf_merge_value(conf->localtime, prev->localtime, 0); | |
ngx_conf_merge_value(conf->exact_size, prev->exact_size, 1); | |
+ ngx_conf_merge_value(conf->escape_href, prev->escape_href, 1); | |
return NGX_CONF_OK; | |
} | |
-- | |
2.18.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 7094ee0c174c37d0b9f6f409b08dfd6f1ec39ea9 Mon Sep 17 00:00:00 2001 | |
From: myfreeer <[email protected]> | |
Date: Fri, 20 Jul 2018 09:39:30 +0800 | |
Subject: [PATCH] install: allow prefix with relative path | |
--- | |
auto/install | 18 ++++++++++++------ | |
1 file changed, 12 insertions(+), 6 deletions(-) | |
diff --git a/auto/install b/auto/install | |
index d884487..5935a70 100644 | |
--- a/auto/install | |
+++ b/auto/install | |
@@ -16,12 +16,18 @@ END | |
fi | |
+if [ "${NGX_PREFIX}" == "" ]; then | |
+ NGX_PREFIX_PATH="" | |
+else | |
+ NGX_PREFIX_PATH="${NGX_PREFIX}/" | |
+fi | |
+ | |
case ".$NGX_SBIN_PATH" in | |
./*) | |
;; | |
*) | |
- NGX_SBIN_PATH=$NGX_PREFIX/$NGX_SBIN_PATH | |
+ NGX_SBIN_PATH=${NGX_PREFIX_PATH}$NGX_SBIN_PATH | |
;; | |
esac | |
@@ -31,7 +37,7 @@ case ".$NGX_MODULES_PATH" in | |
;; | |
*) | |
- NGX_MODULES_PATH=$NGX_PREFIX/$NGX_MODULES_PATH | |
+ NGX_MODULES_PATH=${NGX_PREFIX_PATH}$NGX_MODULES_PATH | |
;; | |
esac | |
@@ -43,7 +49,7 @@ case ".$NGX_CONF_PATH" in | |
;; | |
*) | |
- NGX_CONF_PATH=$NGX_PREFIX/$NGX_CONF_PATH | |
+ NGX_CONF_PATH=${NGX_PREFIX_PATH}$NGX_CONF_PATH | |
;; | |
esac | |
@@ -56,7 +62,7 @@ case ".$NGX_PID_PATH" in | |
;; | |
*) | |
- NGX_PID_PATH=$NGX_PREFIX/$NGX_PID_PATH | |
+ NGX_PID_PATH=${NGX_PREFIX_PATH}$NGX_PID_PATH | |
;; | |
esac | |
@@ -66,7 +72,7 @@ case ".$NGX_ERROR_LOG_PATH" in | |
;; | |
*) | |
- NGX_ERROR_LOG_PATH=$NGX_PREFIX/$NGX_ERROR_LOG_PATH | |
+ NGX_ERROR_LOG_PATH=${NGX_PREFIX_PATH}$NGX_ERROR_LOG_PATH | |
;; | |
esac | |
@@ -76,7 +82,7 @@ case ".$NGX_HTTP_LOG_PATH" in | |
;; | |
*) | |
- NGX_HTTP_LOG_PATH=$NGX_PREFIX/$NGX_HTTP_LOG_PATH | |
+ NGX_HTTP_LOG_PATH=${NGX_PREFIX_PATH}$NGX_HTTP_LOG_PATH | |
;; | |
esac | |
-- | |
2.18.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From f20ec74dfef1ad0e2792a33bef9173679398c3c8 Mon Sep 17 00:00:00 2001 | |
From: myfreeer <[email protected]> | |
Date: Fri, 20 Jul 2018 14:10:25 +0800 | |
Subject: [PATCH] win32: force utf-8 encoding in ngx_dir_t | |
--- | |
src/os/win32/ngx_files.c | 29 +++++++++++++++++++++++++++-- | |
src/os/win32/ngx_files.h | 8 +++++--- | |
2 files changed, 32 insertions(+), 5 deletions(-) | |
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c | |
index 55d7f76..bb3960a 100644 | |
--- a/src/os/win32/ngx_files.c | |
+++ b/src/os/win32/ngx_files.c | |
@@ -427,19 +427,39 @@ ngx_realpath(u_char *path, u_char *resolved) | |
ngx_int_t | |
ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir) | |
{ | |
+ size_t len; | |
+ u_short *u; | |
+ u_short utf16[NGX_UTF16_BUFLEN]; | |
ngx_cpystrn(name->data + name->len, NGX_DIR_MASK, NGX_DIR_MASK_LEN + 1); | |
- dir->dir = FindFirstFile((const char *) name->data, &dir->finddata); | |
+ len = NGX_UTF16_BUFLEN; | |
+ u = ngx_utf8_to_utf16(utf16, name->data, &len); | |
+ | |
+ if (u == NULL) { | |
+ return NGX_ERROR; | |
+ } | |
+ | |
+ dir->dir = FindFirstFileW((LPCWSTR) u, &dir->finddata); | |
name->data[name->len] = '\0'; | |
if (dir->dir == INVALID_HANDLE_VALUE) { | |
+ if (u != utf16) { | |
+ ngx_free(u); | |
+ } | |
return NGX_ERROR; | |
} | |
+ dir->utf8_length = WideCharToMultiByte(CP_UTF8, 0, dir->finddata.cFileName, -1, NULL, 0, NULL, NULL); | |
+ dir->utf8 = calloc(dir->utf8_length, sizeof(char)); | |
+ WideCharToMultiByte(CP_UTF8, 0, dir->finddata.cFileName, -1, dir->utf8, dir->utf8_length, NULL, NULL); | |
+ | |
dir->valid_info = 1; | |
dir->ready = 1; | |
+ if (u != utf16) { | |
+ ngx_free(u); | |
+ } | |
return NGX_OK; | |
} | |
@@ -452,8 +472,12 @@ ngx_read_dir(ngx_dir_t *dir) | |
return NGX_OK; | |
} | |
- if (FindNextFile(dir->dir, &dir->finddata) != 0) { | |
+ if (FindNextFileW(dir->dir, &dir->finddata) != 0) { | |
dir->type = 1; | |
+ free(dir->utf8); | |
+ dir->utf8_length = WideCharToMultiByte(CP_UTF8, 0, dir->finddata.cFileName, -1, NULL, 0, NULL, NULL); | |
+ dir->utf8 = calloc(dir->utf8_length, sizeof(char)); | |
+ WideCharToMultiByte(CP_UTF8, 0, dir->finddata.cFileName, -1, dir->utf8, dir->utf8_length, NULL, NULL); | |
return NGX_OK; | |
} | |
@@ -464,6 +488,7 @@ ngx_read_dir(ngx_dir_t *dir) | |
ngx_int_t | |
ngx_close_dir(ngx_dir_t *dir) | |
{ | |
+ free(dir->utf8); | |
if (FindClose(dir->dir) == 0) { | |
return NGX_ERROR; | |
} | |
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h | |
index 895daea..da98307 100644 | |
--- a/src/os/win32/ngx_files.h | |
+++ b/src/os/win32/ngx_files.h | |
@@ -30,7 +30,9 @@ typedef struct { | |
typedef struct { | |
HANDLE dir; | |
- WIN32_FIND_DATA finddata; | |
+ WIN32_FIND_DATAW finddata; | |
+ char* utf8; | |
+ int utf8_length; | |
unsigned valid_info:1; | |
unsigned type:1; | |
@@ -208,8 +210,8 @@ ngx_int_t ngx_close_dir(ngx_dir_t *dir); | |
#define ngx_dir_access(a) (a) | |
-#define ngx_de_name(dir) ((u_char *) (dir)->finddata.cFileName) | |
-#define ngx_de_namelen(dir) ngx_strlen((dir)->finddata.cFileName) | |
+#define ngx_de_name(dir) ((u_char *) (dir)->utf8) | |
+#define ngx_de_namelen(dir) ((dir)->utf8_length - 1) | |
ngx_int_t ngx_de_info(u_char *name, ngx_dir_t *dir); | |
#define ngx_de_info_n "dummy()" | |
-- | |
2.18.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# init | |
machine_str="$(gcc -dumpmachine | cut -d'-' -f1)" | |
# workaround git user name and email not set | |
GIT_USER_NAME="$(git config --global user.name)" | |
GIT_USER_EMAIL="$(git config --global user.email)" | |
if [[ "${GIT_USER_NAME}" = "" ]]; then | |
git config --global user.name "Build Bot" | |
fi | |
if [[ "${GIT_USER_EMAIL}" = "" ]]; then | |
git config --global user.email "[email protected]" | |
fi | |
# dep versions | |
ZLIB="zlib-1.2.11" | |
PCRE="pcre-8.42" | |
OPENSSL="openssl-1.1.0h" | |
# clone and patch nginx | |
if [[ -d nginx ]]; then | |
cd nginx | |
git checkout master | |
git reset --hard origin || git reset --hard | |
git pull | |
else | |
git clone https://github.com/nginx/nginx.git --depth=1 --config http.sslVerify=false | |
cd nginx | |
fi | |
git checkout -b patch | |
git am -3 ../nginx-*.patch | |
# download deps | |
wget -c -nv "https://download.sourceforge.net/libpng/${ZLIB}.tar.gz" | |
tar -xf "${ZLIB}.tar.gz" | |
wget -c -nv "https://ftp.pcre.org/pub/pcre/${PCRE}.tar.bz2" | |
tar -xf "${PCRE}.tar.bz2" | |
wget -c -nv "https://www.openssl.org/source/${OPENSSL}.tar.gz" | |
tar -xf "${OPENSSL}.tar.gz" | |
# configure | |
configure_args=( | |
--sbin-path=nginx.exe \ | |
--http-client-body-temp-path=temp/client_body \ | |
--http-proxy-temp-path=temp/proxy \ | |
--http-fastcgi-temp-path=temp/fastcgi \ | |
--http-scgi-temp-path=temp/scgi \ | |
--http-uwsgi-temp-path=temp/uwsgi \ | |
--with-select_module \ | |
--with-http_v2_module \ | |
--with-http_realip_module \ | |
--with-http_addition_module \ | |
--with-http_sub_module \ | |
--with-http_dav_module \ | |
--with-http_stub_status_module \ | |
--with-http_flv_module \ | |
--with-http_mp4_module \ | |
--with-http_gunzip_module \ | |
--with-http_gzip_static_module \ | |
--with-http_auth_request_module \ | |
--with-http_random_index_module \ | |
--with-http_secure_link_module \ | |
--with-http_slice_module \ | |
--with-mail \ | |
--with-stream \ | |
--with-pcre=${PCRE} \ | |
--with-pcre-jit \ | |
--with-zlib=${ZLIB} \ | |
--with-openssl=${OPENSSL} \ | |
--with-http_ssl_module \ | |
--with-mail_ssl_module \ | |
--with-stream_ssl_module \ | |
--with-cc-opt='-O2 -pipe -Wall' \ | |
--with-ld-opt='-Wl,--gc-sections,--build-id=none' \ | |
--prefix= | |
) | |
auto/configure ${configure_args[@]} | |
# build | |
make -j$(nproc) | |
strip -s objs/nginx.exe | |
version="$(cat src/core/nginx.h | grep NGINX_VERSION | grep -ioP '((\d+\.)+\d)')" | |
mv -f "objs/nginx.exe" "../nginx-${version}-${machine_str}.exe" | |
# re-configure with debugging log | |
configure_args+=(--with-debug) | |
auto/configure ${configure_args[@]} | |
# re-build with debugging log | |
make -j$(nproc) | |
mv -f "objs/nginx.exe" "../nginx-${version}-${machine_str}-debug.exe" | |
# clean up | |
git checkout master | |
git branch patch -D | |
cd .. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cp -rf nginx/conf . | |
cp -rf nginx/docs/html . | |
rm -rf temp logs | |
mkdir -p temp | |
mkdir -p logs | |
7z a -mx9 nginx-bin.7z nginx-*.exe conf html temp logs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to GitHub
https://github.com/myfreeer/nginx-build-msys2
Readme
Windows builds of
nginx
containing 32-bit and 64-bit version.Badge
Artifacts
nginx-*-i686.exe
: 32-bit nginxnginx-*-i686-debug.exe
: 32-bit nginx with debugging log and symbolsnginx-*-x86_64.exe
: 64-bit nginxnginx-*-x86_64-debug.exe
: 64-bit nginx with debugging log and symbols