From 32bb13c83591644f6e0d5b48752db7fd02d4a730 Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 17:33:22 -0400 Subject: [PATCH 01/11] added workspace --- WORKSPACE | 6 +++ repositories.bzl | 107 +++++++++++++++++++++++++++++++++++++++++++ src/nginx/main/BUILD | 10 +++- 3 files changed, 122 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index d3c87269d..388739f57 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -136,6 +136,7 @@ load( "protobuf_repositories", "servicecontrol_client_repositories", "transcoding_repositories", + "nginx_repositories_brotli" ) bind( @@ -176,6 +177,11 @@ googletest_repositories() transcoding_repositories() +nginx_repositories_brotli( + bind = True, + nginx = "@nginx//", +) + git_repository( name = "gflags_git", commit = "fe57e5af4db74ab298523f06d2c43aa895ba9f98", # 2016-07-22 diff --git a/repositories.bzl b/repositories.bzl index 5ff2c4d88..ba447fc3d 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -602,3 +602,110 @@ def servicecontrol_client_repositories(bind = True): name = "quotacontrol_genproto", actual = "@servicecontrol_client_git//proto:quotacontrol_genproto", ) + + +def nginx_repositories_brotli(bind): + native.git_repository( + name = "org_brotli", + commit = "f83aa5169e3c09afa8db84d1180fd1fe8813118a", + remote = "https://github.com/google/brotli.git", + ) + + if bind: + native.bind( + name = "brotli_enc", + actual = "@org_brotli//:brotli_enc" + ) + + native.bind( + name = "brotli_dec", + actual = "@org_brotli//:brotli_dec" + ) + +def nginx_repositories_ngx_brotli(nginx): + _NGX_BROTLI_BUILD_FILE = """ +# Copyright (C) 2015-2016 Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +licenses(["notice"]) # BSD license +exports_files(["LICENSE"]) +load("{nginx}:build.bzl", "nginx_copts") +cc_library( + name = "http_brotli_filter", + srcs = [ + "src/ngx_http_brotli_filter_module.c", + ], + copts = nginx_copts, + defines = [ + "NGX_HTTP_BROTLI_FILTER", + ], + visibility = [ + "//visibility:public", + ], + deps = [ + "//external:brotli_enc", + "{nginx}:core", + "{nginx}:http", + ], +) +cc_library( + name = "http_brotli_static", + srcs = [ + "src/ngx_http_brotli_static_module.c", + ], + copts = nginx_copts, + defines = [ + "NGX_HTTP_BROTLI_STATIC", + ], + visibility = [ + "//visibility:public", + ], + deps = [ + "{nginx}:core", + "{nginx}:http", + ], +) +cc_binary( + name = "nginx", + srcs = [ + "{nginx}:modules", + ], + copts = nginx_copts, + deps = [ + ":http_brotli_filter", + ":http_brotli_static", + "{nginx}:core", + ], +) +""" + + native.new_git_repository( + name = "ngx_brotli", + build_file_content = _NGX_BROTLI_BUILD_FILE.format(nginx = nginx), + commit = "0fdca2565dbedb88101ca19b1fb1511272f0821f", + remote = "https://nginx.googlesource.com/ngx_brotli", + ) + +def nginx_repositories_brotli(bind = False, nginx = "@nginx//"): + nginx_repositories_ngx_brotli(nginx) + nginx_repositories_brotli(bind) \ No newline at end of file diff --git a/src/nginx/main/BUILD b/src/nginx/main/BUILD index d8b45b261..937931b32 100644 --- a/src/nginx/main/BUILD +++ b/src/nginx/main/BUILD @@ -51,6 +51,7 @@ cc_binary( "@nginx//:http_geo", "@nginx//:http_gunzip", "@nginx//:http_gzip_filter", + "@nginx//:http_brotli_filter", "@nginx//:http_gzip_static", "@nginx//:http_limit_conn", "@nginx//:http_limit_req", @@ -87,6 +88,8 @@ cc_binary( "@nginx//:stream_split_clients", "@nginx//:stream_upstream_hash", "@nginx//:stream_upstream_least_conn", + "@ngx_brotli//:http_brotli_filter", + "@ngx_brotli//:http_brotli_static", ], ) @@ -138,6 +141,8 @@ cc_binary( "@nginx//:stream_split_clients", "@nginx//:stream_upstream_hash", "@nginx//:stream_upstream_least_conn", + "@ngx_brotli//:http_brotli_filter", + "@ngx_brotli//:http_brotli_static", ], ) @@ -156,6 +161,7 @@ genrule( "//:LICENSE", "@nginx//:LICENSE", "@boringssl//:LICENSE", + "@org_brotli//:LICENSE", "@com_github_grpc_grpc//:LICENSE", "@com_github_grpc_grpc//third_party/nanopb:LICENSE.txt", "@nginx_pcre//:LICENCE", @@ -169,10 +175,12 @@ genrule( cmd = "cat $(location //:LICENSE) > $(@);" + "echo \"\n\" >> $(@);" + "echo \"This NGINX binary is statically linked against:\" >> $(@);" + - "echo \"BoringSSL, gRPC, Nanopb, PCRE, Protocol Buffers," + + "echo \"BoringSSL, gRPC, Brotli, Nanopb, PCRE, Protocol Buffers," + " Istio Proxy, Service Control Client & zlib.\" >> $(@);" + "echo \"\n\nBoringSSL license:\n==================\n\" >> $(@);" + "cat $(location @boringssl//:LICENSE) >> $(@);" + + "echo \"\n\nBrotli license:\n===============\n\" >> $(@);" + + "cat $(location @org_brotli//:LICENSE) >> $(@);" + "echo \"\n\ngRPC license:\n=============\n\" >> $(@);" + "cat $(location @com_github_grpc_grpc//:LICENSE) >> $(@);" + "echo \"\n\nNanopb license:\n===============\n\" >> $(@);" + From ce8549a14a0f384d198c9cdc1a72dab2dbf500cf Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 17:34:19 -0400 Subject: [PATCH 02/11] rearrange --- repositories.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repositories.bzl b/repositories.bzl index ba447fc3d..3eb98f195 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -603,8 +603,8 @@ def servicecontrol_client_repositories(bind = True): actual = "@servicecontrol_client_git//proto:quotacontrol_genproto", ) - def nginx_repositories_brotli(bind): + native.git_repository( name = "org_brotli", commit = "f83aa5169e3c09afa8db84d1180fd1fe8813118a", @@ -707,5 +707,5 @@ cc_binary( ) def nginx_repositories_brotli(bind = False, nginx = "@nginx//"): - nginx_repositories_ngx_brotli(nginx) - nginx_repositories_brotli(bind) \ No newline at end of file + nginx_repositories_brotli(bind) + nginx_repositories_ngx_brotli(nginx) \ No newline at end of file From b95b1834a993d6e08074c1711fdb089a173284ff Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 17:35:43 -0400 Subject: [PATCH 03/11] order matters --- repositories.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/repositories.bzl b/repositories.bzl index 3eb98f195..ba447fc3d 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -603,8 +603,8 @@ def servicecontrol_client_repositories(bind = True): actual = "@servicecontrol_client_git//proto:quotacontrol_genproto", ) -def nginx_repositories_brotli(bind): +def nginx_repositories_brotli(bind): native.git_repository( name = "org_brotli", commit = "f83aa5169e3c09afa8db84d1180fd1fe8813118a", @@ -707,5 +707,5 @@ cc_binary( ) def nginx_repositories_brotli(bind = False, nginx = "@nginx//"): - nginx_repositories_brotli(bind) - nginx_repositories_ngx_brotli(nginx) \ No newline at end of file + nginx_repositories_ngx_brotli(nginx) + nginx_repositories_brotli(bind) \ No newline at end of file From 1f4eebf0a11fa62ca8a3eb847ceffdff280e97e0 Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 17:38:15 -0400 Subject: [PATCH 04/11] remove an extra brotli --- src/nginx/main/BUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nginx/main/BUILD b/src/nginx/main/BUILD index 937931b32..582aec919 100644 --- a/src/nginx/main/BUILD +++ b/src/nginx/main/BUILD @@ -51,7 +51,6 @@ cc_binary( "@nginx//:http_geo", "@nginx//:http_gunzip", "@nginx//:http_gzip_filter", - "@nginx//:http_brotli_filter", "@nginx//:http_gzip_static", "@nginx//:http_limit_conn", "@nginx//:http_limit_req", From 2ffb23bd4a58be1fc525ffa0ba154eddc449dee5 Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 17:40:05 -0400 Subject: [PATCH 05/11] rearrange text --- repositories.bzl | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/repositories.bzl b/repositories.bzl index ba447fc3d..f51ecffc9 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -624,32 +624,29 @@ def nginx_repositories_brotli(bind): def nginx_repositories_ngx_brotli(nginx): _NGX_BROTLI_BUILD_FILE = """ -# Copyright (C) 2015-2016 Google Inc. -# All rights reserved. +# Copyright (C) Extensible Service Proxy Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. +################################################################################ # -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. + licenses(["notice"]) # BSD license + exports_files(["LICENSE"]) + load("{nginx}:build.bzl", "nginx_copts") + cc_library( name = "http_brotli_filter", srcs = [ From 06950aa11c903260807bbb3070e2f0db09fd7966 Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 17:46:01 -0400 Subject: [PATCH 06/11] fix a duplicate function name --- WORKSPACE | 4 ++-- repositories.bzl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 388739f57..4b7049499 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -136,7 +136,7 @@ load( "protobuf_repositories", "servicecontrol_client_repositories", "transcoding_repositories", - "nginx_repositories_brotli" + "nginx_repositories_brotli_module" ) bind( @@ -177,7 +177,7 @@ googletest_repositories() transcoding_repositories() -nginx_repositories_brotli( +nginx_repositories_brotli_module( bind = True, nginx = "@nginx//", ) diff --git a/repositories.bzl b/repositories.bzl index f51ecffc9..8fc2f770e 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -703,6 +703,6 @@ cc_binary( remote = "https://nginx.googlesource.com/ngx_brotli", ) -def nginx_repositories_brotli(bind = False, nginx = "@nginx//"): +def nginx_repositories_brotli_module(bind = False, nginx = "@nginx//"): nginx_repositories_ngx_brotli(nginx) nginx_repositories_brotli(bind) \ No newline at end of file From 63a7f2e7ca78d280fc29c318926ee98c7b5e45d7 Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 18:14:37 -0400 Subject: [PATCH 07/11] some extra changes --- WORKSPACE | 22 ++++++--- repositories.bzl | 106 +------------------------------------------ src/nginx/BUILD | 39 ++++++++++++++++ src/nginx/main/BUILD | 8 ++-- 4 files changed, 60 insertions(+), 115 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 4b7049499..568fd324e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -41,6 +41,22 @@ http_archive( urls = ["https://github.com/abseil/abseil-cpp/archive/37d45c0164671963051320598ee8421b87506283.zip"], ) +git_repository( + name = "org_brotli", + commit = "f83aa5169e3c09afa8db84d1180fd1fe8813118a", + remote = "https://github.com/google/brotli.git", +) + +bind( + name = "brotli_enc", + actual = "@org_brotli//:brotlienc" +) + +bind( + name = "brotli_dec", + actual = "@org_brotli//:brotlidec" +) + git_repository( name = "nginx", commit = "2746d4169f5376bb24c119e45aabe4fb70ca7150", # nginx-1.15.9 @@ -136,7 +152,6 @@ load( "protobuf_repositories", "servicecontrol_client_repositories", "transcoding_repositories", - "nginx_repositories_brotli_module" ) bind( @@ -177,11 +192,6 @@ googletest_repositories() transcoding_repositories() -nginx_repositories_brotli_module( - bind = True, - nginx = "@nginx//", -) - git_repository( name = "gflags_git", commit = "fe57e5af4db74ab298523f06d2c43aa895ba9f98", # 2016-07-22 diff --git a/repositories.bzl b/repositories.bzl index 8fc2f770e..bab0d8316 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -601,108 +601,4 @@ def servicecontrol_client_repositories(bind = True): native.bind( name = "quotacontrol_genproto", actual = "@servicecontrol_client_git//proto:quotacontrol_genproto", - ) - - -def nginx_repositories_brotli(bind): - native.git_repository( - name = "org_brotli", - commit = "f83aa5169e3c09afa8db84d1180fd1fe8813118a", - remote = "https://github.com/google/brotli.git", - ) - - if bind: - native.bind( - name = "brotli_enc", - actual = "@org_brotli//:brotli_enc" - ) - - native.bind( - name = "brotli_dec", - actual = "@org_brotli//:brotli_dec" - ) - -def nginx_repositories_ngx_brotli(nginx): - _NGX_BROTLI_BUILD_FILE = """ -# Copyright (C) Extensible Service Proxy Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -################################################################################ -# - -licenses(["notice"]) # BSD license - -exports_files(["LICENSE"]) - -load("{nginx}:build.bzl", "nginx_copts") - -cc_library( - name = "http_brotli_filter", - srcs = [ - "src/ngx_http_brotli_filter_module.c", - ], - copts = nginx_copts, - defines = [ - "NGX_HTTP_BROTLI_FILTER", - ], - visibility = [ - "//visibility:public", - ], - deps = [ - "//external:brotli_enc", - "{nginx}:core", - "{nginx}:http", - ], -) -cc_library( - name = "http_brotli_static", - srcs = [ - "src/ngx_http_brotli_static_module.c", - ], - copts = nginx_copts, - defines = [ - "NGX_HTTP_BROTLI_STATIC", - ], - visibility = [ - "//visibility:public", - ], - deps = [ - "{nginx}:core", - "{nginx}:http", - ], -) -cc_binary( - name = "nginx", - srcs = [ - "{nginx}:modules", - ], - copts = nginx_copts, - deps = [ - ":http_brotli_filter", - ":http_brotli_static", - "{nginx}:core", - ], -) -""" - - native.new_git_repository( - name = "ngx_brotli", - build_file_content = _NGX_BROTLI_BUILD_FILE.format(nginx = nginx), - commit = "0fdca2565dbedb88101ca19b1fb1511272f0821f", - remote = "https://nginx.googlesource.com/ngx_brotli", - ) - -def nginx_repositories_brotli_module(bind = False, nginx = "@nginx//"): - nginx_repositories_ngx_brotli(nginx) - nginx_repositories_brotli(bind) \ No newline at end of file + ) \ No newline at end of file diff --git a/src/nginx/BUILD b/src/nginx/BUILD index 00106d95a..a7dbd44a2 100644 --- a/src/nginx/BUILD +++ b/src/nginx/BUILD @@ -25,6 +25,7 @@ ############################################################################### # load("@protobuf_git//:protobuf.bzl", "cc_proto_library") +load("@nginx//:build.bzl", "nginx_copts") exports_files(["version"]) @@ -50,6 +51,44 @@ cc_library( visibility = [":__subpackages__"], ) + +cc_library( + name = "http_brotli_filter", + srcs = [ + "src/nginx/main/ngx_http_brotli_filter_module.c", + ], + copts = nginx_copts, + defines = [ + "NGX_HTTP_BROTLI_FILTER", + ], + visibility = [ + "//visibility:public", + ], + deps = [ + "//external:brotli_enc", + "@nginx//:core", + "@nginx//:http", + ], +) + +cc_library( + name = "http_brotli_static", + srcs = [ + "src/nginx/main/ngx_http_brotli_static_module.c", + ], + copts = nginx_copts, + defines = [ + "NGX_HTTP_BROTLI_STATIC", + ], + visibility = [ + "//visibility:public", + ], + deps = [ + "@nginx//:core", + "@nginx//:http", + ], +) + cc_proto_library( name = "status_proto", srcs = [ diff --git a/src/nginx/main/BUILD b/src/nginx/main/BUILD index 582aec919..8a152bf36 100644 --- a/src/nginx/main/BUILD +++ b/src/nginx/main/BUILD @@ -36,6 +36,8 @@ cc_binary( linkstatic = 1, deps = [ "//src/nginx:ngx_esp", + "//src/nginx:http_brotli_filter", + "//src/nginx:http_brotli_static", "@nginx//:http", "@nginx//:http_access", "@nginx//:http_addition", @@ -87,8 +89,6 @@ cc_binary( "@nginx//:stream_split_clients", "@nginx//:stream_upstream_hash", "@nginx//:stream_upstream_least_conn", - "@ngx_brotli//:http_brotli_filter", - "@ngx_brotli//:http_brotli_static", ], ) @@ -104,6 +104,8 @@ cc_binary( deps = [ "//src/nginx:ngx_esp", "//src/nginx:version_header", + "//src/nginx:http_brotli_filter", + "//src/nginx:http_brotli_static", "@iap_jwt_verify_nginx//third_party/iap_jwt_verify_nginx/src:ngx_iap_jwt_verify", "@nginx//:http", "@nginx//:http_access", @@ -140,8 +142,6 @@ cc_binary( "@nginx//:stream_split_clients", "@nginx//:stream_upstream_hash", "@nginx//:stream_upstream_least_conn", - "@ngx_brotli//:http_brotli_filter", - "@ngx_brotli//:http_brotli_static", ], ) From 51548d0acbeae8c3116e4ffebeb78995ddcc093b Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 18:21:20 -0400 Subject: [PATCH 08/11] clear out work --- WORKSPACE | 16 ---------------- repositories.bzl | 2 +- src/nginx/BUILD | 39 --------------------------------------- src/nginx/main/BUILD | 9 +-------- 4 files changed, 2 insertions(+), 64 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 568fd324e..d3c87269d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -41,22 +41,6 @@ http_archive( urls = ["https://github.com/abseil/abseil-cpp/archive/37d45c0164671963051320598ee8421b87506283.zip"], ) -git_repository( - name = "org_brotli", - commit = "f83aa5169e3c09afa8db84d1180fd1fe8813118a", - remote = "https://github.com/google/brotli.git", -) - -bind( - name = "brotli_enc", - actual = "@org_brotli//:brotlienc" -) - -bind( - name = "brotli_dec", - actual = "@org_brotli//:brotlidec" -) - git_repository( name = "nginx", commit = "2746d4169f5376bb24c119e45aabe4fb70ca7150", # nginx-1.15.9 diff --git a/repositories.bzl b/repositories.bzl index bab0d8316..5ff2c4d88 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -601,4 +601,4 @@ def servicecontrol_client_repositories(bind = True): native.bind( name = "quotacontrol_genproto", actual = "@servicecontrol_client_git//proto:quotacontrol_genproto", - ) \ No newline at end of file + ) diff --git a/src/nginx/BUILD b/src/nginx/BUILD index a7dbd44a2..00106d95a 100644 --- a/src/nginx/BUILD +++ b/src/nginx/BUILD @@ -25,7 +25,6 @@ ############################################################################### # load("@protobuf_git//:protobuf.bzl", "cc_proto_library") -load("@nginx//:build.bzl", "nginx_copts") exports_files(["version"]) @@ -51,44 +50,6 @@ cc_library( visibility = [":__subpackages__"], ) - -cc_library( - name = "http_brotli_filter", - srcs = [ - "src/nginx/main/ngx_http_brotli_filter_module.c", - ], - copts = nginx_copts, - defines = [ - "NGX_HTTP_BROTLI_FILTER", - ], - visibility = [ - "//visibility:public", - ], - deps = [ - "//external:brotli_enc", - "@nginx//:core", - "@nginx//:http", - ], -) - -cc_library( - name = "http_brotli_static", - srcs = [ - "src/nginx/main/ngx_http_brotli_static_module.c", - ], - copts = nginx_copts, - defines = [ - "NGX_HTTP_BROTLI_STATIC", - ], - visibility = [ - "//visibility:public", - ], - deps = [ - "@nginx//:core", - "@nginx//:http", - ], -) - cc_proto_library( name = "status_proto", srcs = [ diff --git a/src/nginx/main/BUILD b/src/nginx/main/BUILD index 8a152bf36..d8b45b261 100644 --- a/src/nginx/main/BUILD +++ b/src/nginx/main/BUILD @@ -36,8 +36,6 @@ cc_binary( linkstatic = 1, deps = [ "//src/nginx:ngx_esp", - "//src/nginx:http_brotli_filter", - "//src/nginx:http_brotli_static", "@nginx//:http", "@nginx//:http_access", "@nginx//:http_addition", @@ -104,8 +102,6 @@ cc_binary( deps = [ "//src/nginx:ngx_esp", "//src/nginx:version_header", - "//src/nginx:http_brotli_filter", - "//src/nginx:http_brotli_static", "@iap_jwt_verify_nginx//third_party/iap_jwt_verify_nginx/src:ngx_iap_jwt_verify", "@nginx//:http", "@nginx//:http_access", @@ -160,7 +156,6 @@ genrule( "//:LICENSE", "@nginx//:LICENSE", "@boringssl//:LICENSE", - "@org_brotli//:LICENSE", "@com_github_grpc_grpc//:LICENSE", "@com_github_grpc_grpc//third_party/nanopb:LICENSE.txt", "@nginx_pcre//:LICENCE", @@ -174,12 +169,10 @@ genrule( cmd = "cat $(location //:LICENSE) > $(@);" + "echo \"\n\" >> $(@);" + "echo \"This NGINX binary is statically linked against:\" >> $(@);" + - "echo \"BoringSSL, gRPC, Brotli, Nanopb, PCRE, Protocol Buffers," + + "echo \"BoringSSL, gRPC, Nanopb, PCRE, Protocol Buffers," + " Istio Proxy, Service Control Client & zlib.\" >> $(@);" + "echo \"\n\nBoringSSL license:\n==================\n\" >> $(@);" + "cat $(location @boringssl//:LICENSE) >> $(@);" + - "echo \"\n\nBrotli license:\n===============\n\" >> $(@);" + - "cat $(location @org_brotli//:LICENSE) >> $(@);" + "echo \"\n\ngRPC license:\n=============\n\" >> $(@);" + "cat $(location @com_github_grpc_grpc//:LICENSE) >> $(@);" + "echo \"\n\nNanopb license:\n===============\n\" >> $(@);" + From 22b473a181de48222e14de0737e68f690997572b Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 18:27:04 -0400 Subject: [PATCH 09/11] add brotli flag --- WORKSPACE | 1 + 1 file changed, 1 insertion(+) diff --git a/WORKSPACE b/WORKSPACE index d3c87269d..17b4349d1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -52,6 +52,7 @@ load("@nginx//:build.bzl", "nginx_repositories") nginx_repositories( bind = True, nginx = "@nginx//", + ngx_brotli = True, ) # Needs to come after nginx From fe738a0cd5da97a602ea75f87e912ce3583c528f Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 20:28:55 -0400 Subject: [PATCH 10/11] added nginx build --- src/nginx/BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nginx/BUILD b/src/nginx/BUILD index 00106d95a..4dc2f443b 100644 --- a/src/nginx/BUILD +++ b/src/nginx/BUILD @@ -121,5 +121,7 @@ cc_library( "//src/grpc:zero_copy_stream", "@nginx//:core", "@nginx//:http", + "@ngx_brotli//:http_brotli_filter", + "@ngx_brotli//:http_brotli_static", ], ) From 562d26d0db8a4ba75e3781ad2b9cc46c28db1cff Mon Sep 17 00:00:00 2001 From: ilyaGurevich Date: Tue, 7 Apr 2020 22:08:51 -0400 Subject: [PATCH 11/11] added brotli content-encoding test --- src/nginx/t/BUILD | 1 + src/nginx/t/brotli.t | 114 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 src/nginx/t/brotli.t diff --git a/src/nginx/t/BUILD b/src/nginx/t/BUILD index 8d325876b..4e51b46ca 100644 --- a/src/nginx/t/BUILD +++ b/src/nginx/t/BUILD @@ -196,6 +196,7 @@ nginx_suite( "backend_routing_append_path.t", "backend_routing_constant_address.t", "by_consumer_metrics.t", + "brotli.t", "check.t", "check_api_key.t", "check_api_target_blocked.t", diff --git a/src/nginx/t/brotli.t b/src/nginx/t/brotli.t new file mode 100644 index 000000000..5423ebef2 --- /dev/null +++ b/src/nginx/t/brotli.t @@ -0,0 +1,114 @@ +# Copyright (C) Extensible Service Proxy Authors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +################################################################################ +# +use strict; +use warnings; + +################################################################################ + +use src::nginx::t::ApiManager; # Must be first (sets up import path to the Nginx test module) +use src::nginx::t::HttpServer; +use Test::Nginx; # Imports Nginx's test module +use Test::More; # And the test framework + +################################################################################ + +select STDERR; $| = 1; +select STDOUT; $| = 1; + +my $t = Test::Nginx->new()->has(qw/http proxy brotli/)->plan(6); + +$t->write_file_expand('nginx.conf', <<'EOF'); + +%%TEST_GLOBALS%% + +daemon off; + +events { +} + +http { + %%TEST_GLOBALS_HTTP%% + + server { + listen 127.0.0.1:8080; + server_name localhost; + location / { + brotli on; + } + location /proxy/ { + brotli on; + proxy_pass http://127.0.0.1:8080/local/; + } + location /local/ { + brotli off; + alias %%TESTDIR%%/; + } + } +} + +EOF + +$t->write_file('index.html', 'X' x 64); + +$t->run(); + +############################################################################### + +my $r; + +$r = http_brotli_request('/'); +like($r, qr/^Content-Encoding: br/m, 'br'); + +$r = http_brotli_request('/proxy/'); +like($r, qr/^Content-Encoding: br/m, 'br proxied'); + +# Accept-Ranges headers should be cleared + +unlike(http_brotli_request('/'), qr/Accept-Ranges/im, 'cleared accept-ranges'); +unlike(http_brotli_request('/proxy/'), qr/Accept-Ranges/im, + 'cleared headers from proxy'); + +# HEAD requests should return correct headers + +like(http_brotli_request('/'), qr/Content-Encoding: br/, 'br head'); +unlike(http_head('/'), qr/Content-Encoding: br/, 'no br head'); + +############################################################################### + +sub http_brotli_request { + my ($url) = @_; + my $r = http(<