是的又是Quic(H3),在最近我在 nginx-quic 发现目前nginx-quic
已经支持OpenSSL-quic
分支了。
所以 又回来了。顺便彻底排查一下Quic
下WordPress
无法正常使用的原因。
Nginx_Quic + Openssl-Quic
Openssl-quic
仓库地址:https://github.com/quictls/openssl/
Nginx_quic
仓库地址:https://hg.nginx.org/nginx-quic
注:
Openssl-quic
需要perl
否则无法编译。因此需要安装perl
在Fedora
中可以直接使用dnf install perl
来进行安装。
其他系统的话可以自行bing一下。
准备工作
mkdir ~/build
cd ~/build
git clone --recursive https://github.com/quictls/openssl
hg clone -b quic https://hg.nginx.org/nginx-quic
编译OpenSSL
cd ~/build/openssl
./config -Wl,-rpath=/root/openssl/build/lib -fPIC --prefix=/root/openssl/build --openssldir=/root/openssl/build
make -j4
make install
ln -s /root/openssl/build/openssl/lib64/libcrypto.so.81.3 /usr/lib
ln -s /root/openssl/build/openssl/lib64/libssl.so.81.3 /usr/lib
ldconfig
编译Nginx_Quic
cd ~/build/nginx-quic
./auto/configure --with-debug --with-http_v3_module \
--with-cc-opt="-I../openssl/build/include" \
--with-ld-opt="-L../openssl/build/lib64"
make -j4
make install
配置
可以参考README
解决Quic下WordPress无法正常使用问题
归根结底,其实是因为 在Quic下nginx没有传递http_host
给php,即不存在$_SERVER['HTTP_HOST']
,在WordPress下这是致命的,原因不明。
所以我们需要手动传递一个HTTP_HOST
给php
将以下内容丢到fastcgi.conf
中可以暂时解决问题,让WordPress
正常运行。
set $flag 0;
if ($server_port = 443){
set $flag 1;
}
if ($server_port = 80){
set $flag 1;
}
if ($flag = 1){
set $httphost $server_name;
}
if ($flag = 0){
set $httphost $server_name:$server_port;
}
fastcgi_param HTTP_HOST $httphost;