{"id":1741,"date":"2018-07-14T00:00:41","date_gmt":"2018-07-13T16:00:41","guid":{"rendered":"https:\/\/zoco.me\/?p=175"},"modified":"2018-07-14T00:00:41","modified_gmt":"2018-07-13T16:00:41","slug":"debian-rebuild-nginx-support-tls-1-3","status":"publish","type":"post","link":"https:\/\/cloudbool.com\/archive\/debian-rebuild-nginx-support-tls-1-3.html","title":{"rendered":"Debian\u7cfb\u7edf\u7f16\u8bd1\u6253\u5305Nginx\u5e76\u6dfb\u52a0TLS 1.3\u652f\u6301"},"content":{"rendered":"<p>\u524d\u51e0\u5929\u8bf4\u4e86\uff0c<a href=\"https:\/\/zoco.me\/post\/upgrade-https-to-tlsv1-3\">\u5c06HTTPS\u5347\u7ea7\u5230\u4e86TLSv1.3<\/a>\uff0c\u8fd9\u4e48\u591a\u5929\u4e86\uff0c\u7ec8\u4e8e\u6709\u65f6\u95f4\u6574\u7406\u4e0b\u6298\u817e\u8fc7\u7a0b\u4e86\u3002<br \/>\n<!--more--><\/p>\n<p>\u9996\u5148\u9700\u8981\u8bf4\u660e\u7684\u662f\uff0c\u8fd9\u4e9b\u8fc7\u7a0b\u6211\u53ea\u662f\u8bb0\u5f55\uff0c\u4e0d\u4e00\u5b9a\u4fdd\u8bc1\u9002\u5408\u522b\u7684\u60c5\u51b5\uff0c\u6211\u662f\u6839\u636e\u6211\u7684\u5b9e\u9645\u9700\u6c42\u6dfb\u52a0\u4e86\u51e0\u4e2a\u989d\u5916\u7684\u6a21\u5757\uff0c\u76f8\u5bf9\u5e94\u7684\u6b65\u9aa4\u4e5f\u4f1a\u4e0d\u4e00\u6837\u3002<\/p>\n<p>\u9664\u4e86Nginx\u539f\u6709\u7684\u6a21\u5757\u4e4b\u5916\uff0c\u6211\u8fd8\u6dfb\u52a0\u4e86\u5982\u4e0b\u51e0\u4e2a\u6a21\u5757\uff1a<br \/>\n&#8211; ngx_pagespeed<br \/>\n&#8211; ngx_http_google_filter_module<br \/>\n&#8211; ngx_http_substitutions_filter_module<br \/>\n&#8211; nginx_cache_purge<\/p>\n<p>\u8fd9\u51e0\u4e2a\u6a21\u5757\u5206\u522b\u7528\u4e8e\u4e0d\u540c\u7684\u529f\u80fd\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u5230github\u641c\u7d22\u5bf9\u5e94\u7684repo\u8fdb\u884c\u4e86\u89e3\u3002<\/p>\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u9700\u8981\u8bf4\u660e\u7684\u662f\uff0c\u7531\u4e8e\u6211\u4eec\u9700\u8981\u7f16\u8bd1ngx_pagespeed\uff0c\u8fd9\u4e2a\u6a21\u5757\u7684\u7f16\u8bd1\u5bf9\u5185\u5b58\u6709\u4e00\u5b9a\u7684\u9700\u8981\uff0c\u6211\u4e00\u5f00\u59cb\u662f\u5728Vultr\u7684512MB\u5185\u5b58\u7684VPS\u4e0a\u7f16\u8bd1\u7684\uff0c\u7ed3\u679c\u56e0\u4e3a\u5185\u5b58\u4e0d\u8db3\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u62a5\u9519\u9000\u51fa\uff0c\u53ea\u597d\u521b\u5efa\u5feb\u7167\u7136\u540e\u521b\u5efa\u65b0\u7684\u5b9e\u4f8b\u518d\u7ee7\u7eed\u7f16\u8bd1\uff0c\u8fd9\u91cc\u6211\u63a8\u8350\u4f7f\u7528<a href=\"https:\/\/elsenow.com\/go\/vultr\">Vultr<\/a>\uff0c\u53ef\u4ee5\u968f\u65f6\u521b\u5efa\u3001\u5220\u9664\u5b9e\u4f8b\uff0c\u8fd8\u80fd\u5347\u7ea7\u964d\u7ea7\uff0c\u6709\u5168\u740310\u591a\u4e2a\u673a\u623f\u53ef\u9009\u3002<\/p>\n<p>\u56e0\u4e3a\u6211\u662f\u60f3\u5728\u5b98\u65b9Nginx\u5305\u7684\u57fa\u7840\u4e0a\u6dfb\u52a0\u65b0\u6a21\u5757\uff0c\u5e76\u4e14\u6253\u5305\u6210\u65b0\u7684deb\u5b89\u88c5\u5305\u90e8\u7f72\u5230\u522b\u7684\u670d\u52a1\u5668\uff0c\u6240\u4ee5\uff0c\u7edd\u5927\u90e8\u5206\u6587\u4ef6\u90fd\u662f\u5229\u7528\u7cfb\u7edf\u81ea\u5e26\u6216\u8005Nginx\u5b98\u65b9\u5f00\u653e\u7684\u3002<\/p>\n<p>\u6211\u8fd9\u91cc\u9009\u7684\u662fDebian9\uff0c\u5176\u5b9eDebian8\u7cfb\u7edf\u4e5f\u5dee\u4e0d\u591a\u3002\u521b\u5efaVPS\u53ca\u5b89\u88c5\u7cfb\u7edfSSH\u767b\u5f55\u4ec0\u4e48\u7684\u5c31\u4e0d\u8bf4\u4e86\uff0c\u76f4\u63a5\u8bf4\u76f8\u5173\u7684\u6b65\u9aa4\u3002\u7f16\u8bd1\u6253\u5305\u671f\u95f4\u6e90\u7801\u5b58\u653e\u8def\u5f84\u662f<strong>\/usr\/local\/src\/<\/strong>\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6dfb\u52a0Nginx\u5b98\u65b9\u7684\u6e90\uff0c\u53c2\u8003\u8fd9\u91cc\uff1a<a href=\"https:\/\/nginx.org\/en\/linux_packages.html#stable\">Pre-Built Packages for Stable version<\/a>\u3002<\/p>\n<p>\u7136\u540e\u662f\u5b89\u88c5\u7f16\u8bd1\u76f8\u5173\u6240\u9700\u8981\u7684\u4f9d\u8d56\uff1a<\/p>\n<pre><code>apt install build-essential ca-certificates zlib1g-dev libpcre3 libpcre3-dev tar unzip libssl-dev wget curl git\n<\/code><\/pre>\n<p>\u4e0b\u8f7dNginx\u6e90\u4ee3\u7801\u53ca\u76f8\u5173\u6253\u5305\u9700\u8981\u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>cd ~\nmkdir -p ~\/new\/nginx_rebulid\/ #\u521b\u5efa\u65b0\u76ee\u5f55  \u7528\u4e8e\u4fdd\u5b58\u6211\u4eec\u6240\u8981\u4f7f\u7528\u7684\u6587\u4ef6\ncd ~\/new\/nginx_rebulid\/ \napt-get source nginx #\u4e0b\u8f7dNginx\u6e90\u4ee3\u7801\napt-get build-dep nginx  #\u5b89\u88c5\u7f16\u8bd1Nginx\u6240\u9700\u8981\u7684\u4f9d\u8d56\n<\/code><\/pre>\n<p>\u7136\u540e\u662f\u51c6\u5907\u6211\u4eec\u6240\u9700\u8981\u7684\u6a21\u5757\u3002<\/p>\n<h2>\u4e0b\u8f7d\u4f7f\u7528\u65b0\u7684OpenSSL\u7248\u672c<\/h2>\n<p>\u8981\u652f\u6301TLS 1.3\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u65b0\u4e00\u70b9\u7684OpenSSL\u7248\u672c\uff0c\u7cfb\u7edf\u81ea\u5e26\u7684\u80af\u5b9a\u662f\u4e0d\u7528\u8003\u8651\u4e86\uff0c\u4e0b\u8f7d\u4f7f\u7528\u65b0\u7684OpenSSL\uff1a<\/p>\n<pre><code>cd \/usr\/local\/src\/\nwget https:\/\/www.openssl.org\/source\/openssl-1.1.1-pre8.tar.gz\ntar zxvf openssl-1.1.1-pre8.tar.gz\nopenssl-1.1.1-pre8 openssl\n<\/code><\/pre>\n<p>\u5728OpenSSL\u5b98\u7f51\u80fd\u627e\u5230\u6700\u65b0\u7684\u7248\u672c\uff1ahttps:\/\/www.openssl.org\/source\/<br \/>\n\u8fd9\u4e48\u76f4\u63a5\u4f7f\u7528\u4e5f\u53ef\u4ee5\uff0c\u4f46\u662f\u4e3a\u4e86\u517c\u5bb9\u4ee5\u524d\u7684TLS 1.3\u8349\u6848\uff0c\u6211\u8fd8\u662f\u7ed9OpenSSL\u6253\u4e86\u4e2a\u8865\u4e01\uff0c\u53c2\u8003\u7684\u662f<a href=\"https:\/\/www.starduster.me\/2018\/06\/08\/build-nginx-1-15-with-tls13\/\">\u8fd9\u7bc7\u6587\u7ae0<\/a>\u3002<br \/>\n\u4e0b\u8f7d\u5e76patch\u521a\u4e0b\u8f7d\u7684OpenSSL\uff1a<\/p>\n<pre><code>cd \/usr\/local\/src\/\ngit clone https:\/\/github.com\/hakasenyang\/openssl-patch\ncd \/usr\/local\/src\/openssl\npatch -p1 &lt; \/usr\/local\/src\/openssl-patch\/openssl-equal-pre9_ciphers.patch\n<\/code><\/pre>\n<h2>ngx_pagespeed\u6a21\u5757<\/h2>\n<p>\u6700\u65b0\u7684ngx-pagespeed\u7248\u672c\u53ef\u4ee5\u5728<a href=\"https:\/\/github.com\/apache\/incubator-pagespeed-ngx\/releases\">\u8fd9\u91cc<\/a>\u627e\u5230\uff0c\u6211\u76ee\u524d\u7528\u7684\u662f1.13.35.2\uff0c\u4e0b\u9762\u662f\u8fd9\u4e2a\u6a21\u5757\u7684\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n<pre><code>cd \/usr\/local\/src\/\nwget https:\/\/github.com\/apache\/incubator-pagespeed-ngx\/archive\/latest-stable.zip\nunzip latest-stable.zip\ncd incubator-pagespeed-ngx-latest-stable\/\nNPS_VER=1.13.35.2\npsol_url=https:\/\/dl.google.com\/dl\/page-speed\/psol\/${NPS_VERSION}.tar.gz\n[ -e scripts\/format_binary_url.sh ] &amp;&amp; psol_url=$(scripts\/format_binary_url.sh PSOL_BINARY_URL)\nwget ${psol_url}\ntar -xzvf $(basename ${psol_url})\n<\/code><\/pre>\n<h2>ngx_http_google_filter_module\u548cngx_http_substitutions_filter_module<\/h2>\n<p>\u7136\u540e\u662f\u53e6\u5916\u4e24\u4e2a\u6a21\u5757\uff1a<\/p>\n<pre><code>cd \/usr\/local\/src\/\ngit clone https:\/\/github.com\/cuber\/ngx_http_google_filter_module\ngit clone https:\/\/github.com\/yaoweibin\/ngx_http_substitutions_filter_module\n<\/code><\/pre>\n<h2>\u4fee\u6539Nginx\u6253\u5305\u914d\u7f6e\u6587\u4ef6<\/h2>\n<p>\u51c6\u5907\u597d\u6a21\u5757\u4e4b\u540e\uff0c\u6211\u4eec\u5c31\u8981\u5f00\u59cb\u66f4\u6539\u6211\u4eec\u7684Nginx\u6253\u5305\u914d\u7f6e\u4e86\u3002<\/p>\n<pre><code>cd ~\/new\/nginx_rebulid\/nginx-{nginx\u7248\u672c\u53f7}\/debin\/\nvim rules\n<\/code><\/pre>\n<p>\u5176\u5b9e\u6211\u4eec\u8981\u6539\u7684\u5c31\u4e24\u4e2a\u90e8\u5206\uff1a<\/p>\n<pre><code>config.status.nginx: config.env.nginx\n    ...\n\nconfig.status.nginx_debug: config.env.nginx_debug\n    ...\n<\/code><\/pre>\n<p>\u73b0\u6709\u7684\u53ef\u4ee5\u4e0d\u52a8\uff0c\u76f4\u63a5\u5728\u540e\u9762\u6dfb\u52a0\u6211\u4eec\u6240\u9700\u8981\u7684\u9009\u9879\u5c31\u884c\uff0c\u5982\u679c\u4f60\u7684\u9700\u6c42\u548c\u6211\u7684\u4e00\u6837\uff0c\u53ea\u9700\u8981\u5728\u4e0a\u9762\u4e24\u4e2a\u90e8\u5206\u672b\u5c3e\u6dfb\u52a0\u5982\u4e0b\u51e0\u4e2a\u7f16\u8bd1\u9879\u5c31\u884c\uff1a<\/p>\n<pre><code>--add-module=\/usr\/local\/src\/ngx_http_google_filter_module --add-module=\/usr\/local\/src\/ngx_http_substitutions_filter_module --add-module=\/usr\/local\/src\/ngx_cache_purge --with-openssl=\/usr\/local\/src\/openssl --with-openssl-opt=enable-tls1_3 \n<\/code><\/pre>\n<p>\u5982\u56fe\uff1a<br \/>\n<img decoding=\"async\" src=\"https:\/\/cloudbool.com\/archive\/wp-content\/uploads\/2018\/07\/debian-nginx-tls-1.3-pagespeed-google-filter.png\" alt=\"debian-nginx-tls-1.3-pagespeed-google-filter\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u7f16\u8bd1\u5e76\u91cd\u65b0\u6253\u5305\u4e86\u3002<\/p>\n<h2>\u91cd\u65b0\u7f16\u8bd1Nginx\u5e76\u6253\u5305\u6210deb<\/h2>\n<p>\u76f4\u63a5\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u5c31\u884c\uff1a<\/p>\n<pre><code>cd ~\/new\/nginx_rebulid\/nginx-{nginx\u7248\u672c\u53f7}\/\ndpkg-buildpackage -b\n<\/code><\/pre>\n<p>\u7f16\u8bd1\u8fc7\u7a0b\u5341\u6709\u516b\u4e5d\u4f1a\u62a5\u9519\uff0c\u539f\u56e0\u53ef\u4ee5\u770b\u8fd9\u91cc\uff1ahttps:\/\/www.starduster.me\/2018\/06\/08\/build-nginx-1-15-with-tls13\/<\/p>\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229\u7684\u8bdd\uff0c\u4f1a\u5728<strong>~\/new\/nginx_rebulid<\/strong>\u76ee\u5f55\u751f\u6210\u5bf9\u5e94\u7684.deb\u5b89\u88c5\u5305\uff0c\u751f\u6210\u7684.deb\u5b89\u88c5\u5305\uff0c\u53ef\u4ee5\u76f4\u63a5\u5b89\u88c5\u4e5f\u53ef\u4ee5\u4f20\u8f93\u5230\u522b\u7684\u76f8\u540c\u7cfb\u7edf\u76f8\u540c\u67b6\u6784\u7684\u670d\u52a1\u5668\u5b89\u88c5\uff0c\u5b89\u88c5\u4e5f\u5f88\u7b80\u5355\uff0c\u4e00\u884c\u547d\u4ee4\u641e\u5b9a\uff1a<\/p>\n<pre><code>dpkg -i nginx_1.14.0-1~stretch_amd64.deb\n<\/code><\/pre>\n<p>\u5b89\u88c5\u4e4b\u540e\uff0c\u67e5\u770b\u6211\u4eec\u521a\u624d\u914d\u7f6e\u7684\u7f16\u8bd1\u9009\u9879\uff1a<\/p>\n<pre><code>nginx -V\n\nconfigure arguments: --prefix=\/etc\/nginx --sbin-path=\/usr\/sbin\/nginx --modules-path=\/usr\/lib\/nginx\/modules --conf-path=\/etc\/nginx\/nginx.conf --error-log-path=\/var\/log\/nginx\/error.log --http-log-path=\/var\/log\/nginx\/access.log --pid-path=\/var\/run\/nginx.pid --lock-path=\/var\/run\/nginx.lock --http-client-body-temp-path=\/var\/cache\/nginx\/client_temp --http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp --http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp --http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp --http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=\/root\/new\/nginx_rebulid\/nginx-1.14.0=. -specs=\/usr\/share\/dpkg\/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC -Wno-error' --with-ld-opt='-specs=\/usr\/share\/dpkg\/no-pie-link.specs -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-module=\/usr\/local\/src\/ngx_http_google_filter_module --add-module=\/usr\/local\/src\/ngx_http_substitutions_filter_module --add-module=\/usr\/local\/src\/ngx_cache_purge --with-openssl=\/usr\/local\/src\/openssl --with-openssl-opt=enable-tls1_3\n<\/code><\/pre>\n<p>\u770b\u6700\u540e\u51e0\u884c\uff0c\u8bf4\u660e\u6210\u529f\u52a0\u5165\u4e86\u6211\u4eec\u6240\u9700\u8981\u7684\u6a21\u5757\uff0c\u4e0b\u4e00\u6b65\u5c31\u662f\u914d\u7f6eNginx\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u51e0\u5929\u8bf4\u4e86\uff0c\u5c06HTTPS\u5347\u7ea7\u5230\u4e86TLSv1.3\uff0c\u8fd9\u4e48\u591a\u5929\u4e86\uff0c\u7ec8\u4e8e\u6709\u65f6\u95f4\u6574\u7406\u4e0b\u6298\u817e\u8fc7\u7a0b\u4e86\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[53,76],"class_list":["post-1741","post","type-post","status-publish","format-standard","hentry","category-tech","tag-https","tag-nginx"],"_links":{"self":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/comments?post=1741"}],"version-history":[{"count":0,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1741\/revisions"}],"wp:attachment":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/media?parent=1741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/categories?post=1741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/tags?post=1741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}