http3

ย 
ย 
๋ชฉ์ฐจ
Nginx โ€“ quic http3 ์„ค์น˜๋ฐฉ๋ฒ•
  • Nginx
tar xzvf nginx-1.19.3.tar.gz
cd nginx-1.19.3.tar.gz
patch โ€“p01 < ../quiche/extras/nginx/nginx-1.16.patch
  • ํŒจ์น˜ํ•˜์—ฌ http3 ๋ชจ๋“ˆ ๋นŒ๋“œ
  • Nginx ๋ชจ๋“ˆ ๋นŒ๋“œ
./configure --with-debug \
--prefix=/usr/share/nginx \
  • -with-http_ssl_module \
  • -with-http_v2_module \
  • -with-http_v3_module \
--with-openssl=../quiche/deps/boringssl \
--with-quiche=../quiche \
  • -sbin-path=/usr/sbin/nginx \
--modules-path=/usr/share/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=/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=www-data \
--group=www-data \
--with-threads \
--with-file-aio \
  • -with-http_realip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_slice_module \
--with-http_stub_status_module \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--without-select_module \
--without-poll_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--add-dynamic-module=../headers-more-nginx-module \
--build="quiche-$(git --git-dir=../quiche/.git rev-parse --short HEAD)" \
  • -with-cc-opt="-I../boringssl/include" \
--with-ld-opt="-L../boringssl/build/ssl \
-L../boringssl/build/crypto"
make
make install
  • Nginx config
  1. h3๋ฅผ ์œ„ํ•œ ์ตœ์†Œํ•œ์˜ ์„ค์ •
http {
server {
listen 443 quic reuseport;
listen 443 ssl http2;
proxy_request_buffering off;
ssl_early_data on;
ssl_certificateย ย ย ย ย  /etc/ssl/mywebsite/fullchain.pem;
ssl_certificate_keyย  /etc/ssl/mywebsite/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
add_header Alt-Svc 'h3-29=":443"; ma=2592000, h3-28=":443"; ma=2592000, H3-27=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q043=":443"; ma=2592000, quic=":443"; ma=2592000; v="46,43"';
}
}ย ย -----------------------------------------------------------------------ย ย ย user www-data;
load_module modules/ngx_http_headers_more_filter_module.so;
worker_processes auto;
events {
worker_connectionsย  1024;
}
http {
includeย ย ย ย ย ย  mime.types;
default_typeย  application/octet-stream;
gzipย  on;
server {
listen 80;
listen [::]:80;
server_name _;
access_log off;
error_log off;
return 301 https://yourdomain.com$request_uri;
}
server {
listen 443 quic reuseport default_server;
listen 443 ssl http2;
proxy_request_buffering off;
client_max_body_size 100M;
server_name yourdomain.com;
ssl_early_data on;
ssl_certificateย ย ย ย ย  /etc/letsencrypt/mywebsite/fullchain.pem;
ssl_certificate_keyย  /etc/letsencrypt/mywebsite/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
add_header Alt-Svc 'h3-29=":443"; ma=2592000, h3-28=":443"; ma=2592000, H3-27=":443"; ma=2592000, h3-Q050=":443"; ma=2592000, h3-Q046=":443"; ma=2592000, h3-Q043=":443"; ma=2592000, quic=":443"; ma=2592000; v="46,43"';
root /var/www/html/projek;
location '/.well-known/acme-challenge' {
default_type "text/plain";
root /var/www/html/projek;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_read_timeout 120;
fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match;
fastcgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since;
}
}
}
  • Boringssl
cd boringssl
mkdir build
cd build
cmake ..
make
  • quiche ์— ์žˆ์ง€๋งŒ ๋”ฐ๋กœ ํ•„์š”ํ•  ์‹œ์—
Nginx-quic ์—์„œ๋Š” Openssl ๋Œ€์‹ ย  boringsslย  ์„ ์‚ฌ์šฉํ•œ๋‹ค
Quiche์— ์žˆ์–ด์„œ ์‚ฌ์šฉ
  • Quiche
cd quiche
cargo build โ€“examples
cargo test
  • Nginx header modul
  • ์ถ”๊ฐ€ ๋ชจ๋“ˆ์ด ํ•„์š”ํ• ์‹œ์—
  • Nginx-common
apt-get install nginx-common
rm /usr/share/nginx/modules
  • ์—†์–ด๋„ ์ •์ƒ ๋™์ž‘ ํ–ˆ์Œ
  • Os ํŒจํ‚ค์ง€
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
apt-get install dialog mercurial gcc-multilib git cmake g++
apt-get install curl
apt-get install libunwind-dev
  • ํ•„์š”ํ•œ๊ฑฐ๋งŒ install ํ•˜๋ฉด ๋จ
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
  • ์ธ์ฆ๋œ ๋„๋ฉ”์ธ
  • ๊ธฐ์กด ์ ‘์†์‹œ ์•ˆ์ „ํ•˜์ง€ ์•Š์Œ์œผ๋กœ ๋“ค์–ด๊ฐ€์ง€๋Š” ๊ฒƒ์ฒ˜๋Ÿผ์€ ์•ˆ๋˜์—ˆ๊ณ 
๊ธฐ๊ด€์— ์ธ์ฆ์„ ๋ฐ›์€ ๋„๋ฉ”์ธ๋งŒ ์ ‘์† ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
ํ…Œ์ŠคํŠธ ๋‹น์‹œ
๋ฌด๋ฃŒ๋„๋ฉ”์ธ์„ ๋ฐ›์€ ๋’ค์—
https://zerossl.com/ ์ด ์‹ธ์ดํŠธ์—์„œ ssl ์ธ์ฆ์„ ๋ฐ›์•˜๋‹ค
  • ์„ค์น˜ ํ›„ ํ…Œ์ŠคํŠธ
1.http3check.net/ ์— ๋„๋ฉ”์ธ ์ž…๋ ฅ ํ›„ ํ™•์ธ
2.๊ฐœ๋ฐœ์ž ๋„๊ตฌ ๋„คํŠธ์›Œํฌ ํƒญ์—์„œย  H3-29 ํ”„๋กœํ† ์ฝœ ํ™•์ธ
3.๋‚˜์˜ค์ง€ ์•Š์„ ์‹œ์— ๋ธŒ๋ผ์šฐ์ € quicย  ํ™œ์„ฑํ™” ํ™•์ธ
ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ € ์„ค์ •
  • chrome://flags/#enable-quic
cmd
cd โ€ฆ. Chrome.exe ํŒŒ์ผ์ด ์žˆ๋Š” ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ ํ›„
  • ์ฐธ๊ณ  ์‚ฌ์ดํŠธ
//docker์— debian os ์ด๋ฏธ์ง€๋ฅผ ๋ฐ›์•„ ์„ค์น˜ํ•˜๋Š” ๊ณผ์ •์„ ์ˆœ์ฐจ์ ์œผ๋กœ ๋ณด์—ฌ์คŒ
//nginx-quic ์ตœ์†Œํ•œ์˜ ์„ค์ •์œผ๋กœ ์„ค์น˜ ํ•˜๋Š” ๋ฐฉ๋ฒ•
  • ํŒจํ‚ค์ง€ ์•„๋ฌด๊ฒƒ๋„ ์—†์—ˆ์„ ๋•Œ centos ์—์„œ ์„ค์น˜ํ–ˆ๋˜ ํŒจํ‚ค์ง€๋“ค
yum install git
yum install patch
yum install -y httpd-devel pcre perl pcre-devel zlib zlib-devel GeoIP GeoIP-devel
yum -y install gcc g++ cpp gcc-c++ openssl openssl-devel gd gd-devel libxml2-devel bzip2-devel curl-devel libicu-devel libmcrypt libmcrypt-devel openldap openldap-devel libxslt-devel
yun install cmake(3.0 ์ด์ƒ ํ™ˆํŽ˜์ด์ง€ ๋”ฐ๋กœ ๋ฐ›์•„์•ผํ•จ)
Centos 7.2.1511
1.์ฐธ๊ณ 
  • nginx-quic์ด ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜๋ ค๋ฉด OpenSSL์ด ์•„๋‹Œ BoringSSl๋กœ ๋นŒ๋“œํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค..
  • openssl ver 1.1.1 ์ด์ƒ3 ์ง€์›ํ•˜๋Š” ๋ฒ„์ „
  • ๊ธฐ๊ด€์— ์ธ์ฆ๋ฐ›์€ ๋„๋ฉ”์ธ์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    • ํ…Œ์ŠคํŠธ ํ–ˆ์„ ์‹œ์— (์•ˆ์ „ํ•˜์ง€ ์•Š์€ ์‚ฌ์ดํŠธ)์ ‘๊ทผ ๋ถˆ๊ฐ€
  • Make๋ฅผ ์ด์šฉํ•œ ์ปดํŒŒ์ผ์‹œ0๋ฒ„์ „ ์ด์ƒ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
    • cmake 3 ๋ฒ„์ „ ์ด์ƒ
    • 2021-07-16 ๊ธฐ์ค€ ํ™ˆํŽ˜์ด์ง€ ์—์„œ ๋”ฐ๋กœ ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค.
  • Rust์˜ ํŒจ๊ธฐ์ง€ ๊ด€๋ฆฌ์žCargo quiche ๋นŒ๋“œ๋ฅผ ์œ„ํ•ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
  • ์•„๋ž˜ ์„ค์น˜ ๋ฐฉ๋ฒ•์€ /tmp ๊ฒฝ๋กœ์—์„œ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.
2.nginx ์†Œ์Šค์ฝ”๋“œ ๋‹ค์šด๋กœ๋“œ
  • tar xzvf nginx-1.19.3.tar.gz
  • cd nginx-1.19.3
  • patch -p01 < ../quiche/extras/nginx/nginx-1.16.patch
    • 3์—์„œ ๋ฐ›์€ quiche ๊ฒฝ๋กœ์— ์žˆ๋Š” nginx-1.16.patch (ํ˜„์žฌ) ๋กœ http3 ๋ชจ๋“ˆ ํ™œ์„ฑํ™” ํ•ฉ๋‹ˆ๋‹ค.
  • ./configure \
--prefix=/tmp/nginxย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  \
--build="quiche-$(git --git-dir=../quiche/.git rev-parse --short HEAD)" \
--with-http_ssl_moduleย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  \
--with-http_v2_moduleย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  \
--with-http_v3_moduleย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  \
--with-openssl=../quiche/deps/boringssl \
--with-quiche=../quiche
  • http3 ๋ชจ๋“ˆ ํ™œ์„ฑํ™” ํ›„ nginx ์— ๋นŒ๋“œ ํ•ฉ๋‹ˆ๋‹ค.
  • ๋นŒ๋“œ์‹œ์— pcre ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ•„์š”ํ•˜๋‹ค๊ณ  ํ•ด์„œ
  • yum install pcre-devel ํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.
  • make
    • ๋นŒ๋“œ๋œ nginx make ์ปดํŒŒ์ผ
    • ์‹คํŒจํ–ˆ์„ ๊ฒฝ์šฐ
      • Openssl ๋ฒ„์ „์ด1.1 ์ธ์ง€ ํ™•์ธ
        • ์ง€์›ํ•˜๋Š” ๋ชจ๋“ˆ์ค‘์—3 ์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
        • yum group install โ€˜Development Toolsโ€™
        • yum install perl-core zlib-devel โ€“y
        • wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
        • tar -xvzf openssl-1.1.1a.tar.gz
        • ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared
        • Make && make insatall
        • ๋งํฌ์„ค์ •ํ›„ openssl version ์œผ๋กœ ํ™•์ธ
        • ์ฐธ๊ณ  ์ž๋ฃŒ : http://blog.plura.io/?p=9209
      • ์‹คํŒจ์‹œ์— cmake โ€“-version 3๋ฒ„์ „ ์ด์ƒ์ธ์ง€ ํ™•์ธ
      • Quiche ๋นŒ๋“œ๋ฅผ ์œ„ํ•œ cargo Rustup(https://rustup.rs)
        • curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
        • source $HOME/.cargo/env
      • nginx ๋นŒ๋“œ ํ™•์ธ
        • Prefix ๋นŒ๋“œ ๊ฒฝ๋กœ์—์„œ nginx โ€“v quiche ํ™•์ธ
      • conf ํŒŒ์ผ ์ˆ˜์ •
        • ํ•„์ˆ˜ํ•ญ๋ชฉ
          • ์ง€์‹œ์–ด quic ๋˜๋Š” http3 ์‚ฌ์šฉํ›„ reuseport
          • 3
          • Ssl ์ธ์ฆ์„œ ๊ฒฝ๋กœ
          • Header h3-29
        • Nginx ์„ค์ • ํ™•์ธ
        • ํฌํŠธ ํ™•์ธ
          • UDP 443 ํฌํŠธ๊ฐ€ ์—ด๋ฆฐ ๊ฒƒ์„ ํ™•์ธ ํ–ˆ์Šต๋‹ˆ๋‹ค.
          • ๋งŒ์•ฝ ์—†์„์‹œ์—๋Š” ๋ฐฉํ™”๋ฒฝ์—์„œ ์—ด์–ด์ฃผ์„ธ์š”
http3 ๋ธŒ๋ผ์šฐ์ € ์ ‘์†
  • ์บ์‹œ ์‚ญ์ œ
๋Œ“๊ธ€ 0๊ฐœ

๋“ฑ๋ก๋œ ๋Œ“๊ธ€์ด ํ•˜๋‚˜๋„ ์—†์Šต๋‹ˆ๋‹ค...๐Ÿ˜ข