大网数据广告活动
服务器运维问答

Nginx with http2 and ios WKWebView

· 52CE 我爱测

We are running nginx on a debian system as our loadbalancer nginx version: nginx/1.9.10 built with OpenSSL 1.0.2e 3 Dec 2015 (running with OpenSSL 1.0.2g 1 Mar 2016) We had http2 activated in our server like this: server { listen…

问题原文

原帖链接 · Janning · CC BY-SA 3.0

We are running nginx on a debian system as our loadbalancer

nginx version: nginx/1.9.10
built with OpenSSL 1.0.2e 3 Dec 2015 (running with OpenSSL 1.0.2g  1 Mar 2016)

We had http2 activated in our server like this:

server {
   listen 443 ssl http2;
   ....
}

All requests are proxied to our application server. We are logging the request_time and upstream_time from nginx.

We switched recently our iOS hybrid app from UIWebView to WKWebView in Week 13, see what happened:

The upstream_time stayed the same but our request time suddenly raised as more and more users updated their app to the new version.

Today we decided to give it a try and deactivate http2. We only removed the word "http2" from our server config:

server {
   listen 443 ssl;
   ....
}

See what happened:

It seems http2 is not production ready. I don't know if it is server side or client side. Maybe even the request_time is not properly logged inside nginx.

Does anybody has more info about using http2 with nginx and/or WKWebView?

已采纳解答

原帖链接 · Anubioz · CC BY-SA 3.0

Research suggest there is a bug in Ubuntu/Debian nginx package which causes low http2 performance, you need to use alternative distribution/compile nginx from source code yourself (it's really easy and will take like 5 minutes of your time).

For debian you may have to replace that configuration line in that building guide with something like:

 ./configure --with-cc-opt='-march=native -O2 -pipe' --prefix=/usr --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-pcre-jit --with-ipv6 --with-file-aio --with-ipv6 --with-http_v2_module --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module -with-http_v2_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --user=www-data --group=www-data --with-openssl=../openssl-1.0.2h --add-module=../nginx-http-auth-digest --add-module=../ngx_cache_purge --add-module=../ngx_pagespeed-release-1.11.33.2-beta

Or just use any recent guide on the internet. It must have building with OpenSSL 1.0.2h version or higher in it, or it's just not recent enough. Here is one that should do: https://ethitter.com/2016/06/nginx-openssl-1-0-2-http-2-alpn/

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。