扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
配置nginx使用http2
一、配置openssl
openssl版本需大于1.0.2版本
yum install -y gcc zlib-devel pcre-devel
wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz
tar zxvf openssl-1.1.0g.tar.gz
cd openssl-1.1.0g
./config --prefix=/usr/local/openssl shared zlib
make && make install
mv /usr/bin/openssl /usr/bin/openssl.old
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /lib/x86_64-linux-gnu
echo /usr/local/openssl/lib >> /etc/ld.so.conf
ln -s /usr/local/openssl/lib/libssl.so /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/lib/libcrypto.so /usr/local/lib64/libcrypto.so
ldconfig -v 使配置生效
openssl version 查看版本
为香坊等地区用户提供了全套网页设计制作服务,及香坊网站建设行业解决方案。主营业务为成都网站设计、成都做网站、香坊网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
tar xf nginx-1.14.2.tar.gz
cd nginx-1.14.2
vim src/core/nginx.h 去除版本信息,这两行修改成
#define NGINX_VERSION ""
#define NGINX_VER "Tengine/" NGINX_VERSION
./configure --prefix=/usr/local/nginx --with-http_v2_module --with-http_ssl_module
make && make install
cd /usr/local/nginx
二、配置nginx.conf
vim conf/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip_min_length 1k;
gzip_comp_level 6;
gzip on;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/png application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;
server {
listen 80;
server_name abc.com;
rewrite "^/(.*)$" https://abc.com$1; #强制访问到https
}
server {
listen 443 ssl http2 ; #http2必须用https
server_name abc.com;
ssl_certificate /root/ssl/fullchain.crt;
ssl_certificate_key /root/ssl/private.pem;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
location / {
root html;
index index.html index.htm;
}
}
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流