nginx HTTP 2 지원 을 사용 하 는 방법 | nginx HTTP 2 가 사용 되 었 는 지 확인 하 는 방법
현재 nginx 의 컴 파일 옵션 보기
1 #./nginx -V 2 3 nginx version: nginx/1.9.15 4 built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5 built with OpenSSL 1.0.2g 1 Mar 2016 6 TLS SNI support enabled 7 configure arguments: --prefix=/home/jackie/software/nginx --with-openssl=/home/jackie/Downloads/nginx/openssl-1.0.2g --with-pcre=/home/jackie/Downloads/nginx/pcre-8.38 --with-zlib=/home/jackie/Downloads/nginx/zlib-1.2.8 --with-http_ssl_module --with-threads --with-debug http2 지원 사용 하기
configure 옵션 에 추가 --with-http_v2_module 하고, HTTP 2 는 SSL 지원 이 필요 하기 때문에 --with-http_ssl_module 옵션 이 부족 하면 추가 --with-http_ssl_module 해 야 합 니 다.다음 과 같다. ./configure --prefix=/home/jackie/software/nginx \
--with-openssl=/home/jackie/Downloads/nginx/openssl-1.0.2g \
--with-pcre=/home/jackie/Downloads/nginx/pcre-8.38 \ --with-zlib=/home/jackie/Downloads/nginx/zlib-1.2.8 \ --with-http_ssl_module \ --with-threads \ --with-debug \ --with-http_v2_module make & make install
server {
listen 8443 ssl http2 default_server; # http2 default_server
server_name 192.168.0.107;
...
}
#./nginx -t
nginx: the configuration file /home/jackie/software/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /home/jackie/software/nginx/conf/nginx.conf test is successful
#./nginx
방법 1
고 버 전 56.0.2924.87 과 같은 Chrome 을 사용 하여 다음 과 같은 절차 로 조작 합 니 다.
chrome://net-internals/#http2 입력 하고 HTTP/2 sessions 아래 표를 검사 합 니 다.방법 2
curl 명령 을 사용 합 니 다. HTTP / 2 with curl 을 참고 하여 다음 명령 을 실행 하고 사이트 에서 돌아 오 는 프로 토 콜 이 HTTP 인지 확인 합 니 다.
curl --http2 -I 192.168.0.107:8443
위 명령 을 실행 할 때 다음 과 같은 오류 가 발생 하면 시스템 에 현재 설 치 된 curl 이 HTTP 2 프로 토 콜 을 지원 하지 않 는 다 는 것 을 설명 합 니 다.
curl https://192.168.0.107:8443/ --http2
curl: (1) Unsupported protocol
다음 명령 을 실행 할 수 있 습 니 다. 시스템 에 현재 설 치 된 curl 이 지원 하 는 특성 목록 을 확인 하고 HTTP 2 가 포함 되 어 있 는 지 확인 할 수 있 습 니 다.
curl -V
curl 7.47.0 (i686-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets 앞에서 말 한 출력 정 보 를 통 해 알 수 있 듯 이 현재 설 치 된 curl 은 HTTP 2 를 지원 하지 않 습 니 다.이 때 curl 명령 HTTP 2 를 사용 하여 curl 을 재 컴 파일 하고 HTTP 2 지원 을 추가 하 는 방법 을 참고 할 수 있 습 니 다.
방법
Chrome 플러그 인 HTTP / 2 and SPDY indicator 를 설치 하고 설치 가 완료 되면 HTTP 2 를 사용 하 는 사이트 에 방문 합 니 다. 주소 표시 줄 에 파란색 번개 가 치면 사이트 에서 HTTP 2 를 사용 하고 있 음 을 설명 합 니 다.그러나 재 키 는 벽 안에 있어 설치 가 항상 실패 하기 때문에 이 방법의 유효성 을 검증 하지 못 했다.
전체 프로필
다음은 완전한 프로필 입 니 다. HTTP 2 특성 과 관련 이 없 는 내용 을 삭 제 했 습 니 다.
01 worker_processes 1; 02 error_log logs/error.log debug; 03 04 events { 05 worker_connections 1024; 06 } 07 08 http { 09 include mime.types; 10 default_type application/octet-stream; 11 server_tokens off; 12 13 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 14 '$status $body_bytes_sent "$http_referer" ' 15 '"$http_user_agent" "$http_x_forwarded_for"' ; 16 17 access_log logs/access.log main; 18 19 sendfile on; 20 tcp_nopush on; 21 22 keepalive_timeout 65; 23 charset utf-8; 24 25 server { 26 listen 8080; 27 server_name 192.168.0.107; 28 if ( $scheme ~ http) { 29 return https: //$server_name:8443$request_uri; 30 } 31 } 32 33 server { 34 listen 8443 ssl http2 default_server; 35 server_name 192.168.0.107; 36 37 ssl_certificate /home/jackie/software/nginx_conf/server.crt; 38 ssl_certificate_key /home/jackie/software/nginx_conf/server.key; 39 40 ssl_session_cache shared:SSL:1m; 41 ssl_session_timeout 5m; 42 43 ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA' ; 44 ssl_prefer_server_ciphers on; 45 46 add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" always; 47 add_header X-Frame-Options SAMEORIGIN always; 48 add_header X-XSS-Protection "1; mode=block" always; 49 add_header X-Content-Type-Options nosniff; 50 51 location ~ / { 52 index index.jsp; 53 proxy_pass http: //127.0.0.1:18080; 54 proxy_set_header referer '' ; 55 include proxy.conf; 56 } 57 58 #error_page 404 /404.html; 59 60 # redirect server error pages to the static page /50x.html 61 # 62 error_page 500 502 503 504 /50x.html; 63 location = /50x.html { 64 root html; 65 } 66 67 location ~ /\. { 68 deny all; 69 access_log off; 70 log_not_found off; 71 } 72 } 73 74 } 다음으로 전송:https://www.cnblogs.com/interdrp/p/7894489.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.