設置 | 登錄 | 註冊

目前共有8篇帖子。

CentOS7自带的nginx-1.20.1是支持HTTP/2和TLS1.3的

1樓 巨大八爪鱼 2024-7-3 20:57
软件包名称:nginx-1.20.1-10.el7.x86_64

CentOS7默认开启了HTTP/2,但没有开启TLS1.3,以及IE6和IE8的https访问。

开启方法:

ssl_ciphers HIGH:!aNULL:!MD5;改为ssl_ciphers HIGH:MEDIUM:!MD5:!RC4;

添加一行ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

然后sudo systemctl restart nginx重启服务器即可。

2樓 巨大八爪鱼 2024-7-3 21:44
nginx目前已经有HTTP/3模块了(实验性模块),但apache还没做这种模块。
3樓 巨大八爪鱼 2025-3-10 14:18
[oct1158@cxywxvxep temp]$ nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1k  FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
[oct1158@cxywxvxep temp]$ openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

居然用的不是同一个openssl。。。
巨大八爪鱼今天突然发现这种方法失效了,sslv3不行了,ie6无法访问https。
4樓 巨大八爪鱼 2025-3-10 15:17
2025年3月10日,突然发现该方法失效,IE6无法访问https。
因为前几天刚把/opt目录下没有用的自编译的httpd2.4.59和openssl1.1.1w(支持SSLv3)删除了。
以前nginx可能碰巧引用到了自编译的openssl1.1.1w的库文件,所以IE6可以正常访问https。
现在没有openssl1.1.1w了,nginx可能就跑去引用自身的不支持SSLv3的openssl1.1.1k了,IE6就无法访问了。

$ nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1k  FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: (略)

$ openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

由此可见nginx自带了一个openssl1.1.1k,不是centos7系统里面的那个openssl1.0.2k。
5樓 巨大八爪鱼 2025-3-10 16:49
【手工编译安装nginx(里面包含支持ssl3的openssl)】
cd ~
wget https://nginx.org/download/nginx-1.27.4.tar.gz
tar xf nginx-1.27.4.tar.gz
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
tar xf openssl-1.1.1w.tar.gz

cd nginx-1.27.4
./configure --prefix=/opt/nginx-1.27.4 --with-http_ssl_module --with-openssl=../openssl-1.1.1w --with-openssl-opt="enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers" --with-http_v2_module
make
sudo make install

安装完成后,/opt下只有一个nginx-1.27.4文件夹,没有单独的openssl文件夹。
查看编译出来的nginx可执行文件的版本:
$ /opt/nginx-1.27.4/sbin/nginx -V
nginx version: nginx/1.27.4
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1w  11 Sep 2023
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx-1.27.4 --with-http_ssl_module --with-openssl=../openssl-1.1.1w --with-openssl-opt='enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers' --with-http_v2_module
可见openssl是被直接打包到nginx可执行文件里面了。

【测试】
启动:sudo /opt/nginx-1.27.4/sbin/nginx
重启:sudo /opt/nginx-1.27.4/sbin/nginx -s reload
关闭:sudo /opt/nginx-1.27.4/sbin/nginx -s stop

【开启https(支持IE6)】
修改/opt/nginx-1.27.4/conf/nginx.conf文件,取消注释有listen 443的那个server块。
把ssl_certificate和ssl_certificate_key改成自己的证书文件。
ssl_ciphers  HIGH:!aNULL:!MD5;改成ssl_ciphers HIGH:MEDIUM:!MD5:!RC4;
下面加一句ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
重启nginx服务器即可用IE6访问。

【开启http2】
server_name  localhost;下面加一句http2 on;
重启nginx服务器。

【开机启动(这个方法只能用于CentOS系统)】
关闭nginx服务器:sudo /opt/nginx-1.27.4/sbin/nginx -s stop
创建/usr/lib/systemd/system/opt_nginx.service文件,内容如下:
[Unit]
Description=opt_nginx
After=network.target

[Service]
Type=forking
ExecStartPre=/opt/nginx-1.27.4/sbin/nginx -t
ExecStart=/opt/nginx-1.27.4/sbin/nginx
ExecReload=/opt/nginx-1.27.4/sbin/nginx -s reload
ExecStop=/opt/nginx-1.27.4/sbin/nginx -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

启动nginx服务器:sudo systemctl start opt_nginx
设置为开机启动:sudo systemctl enable opt_nginx

【其他设置】
设置上传文件的最大尺寸:
http块内,server块外添加
# set maximum post size
client_max_body_size 20m;
6樓 巨大八爪鱼 2025-3-10 16:50
【PHP配置】
server块的location /内:
index index.html index.htm index.php;
location /外的下方:
include /home/oct1158/config/nginx/php-fpm.conf;

php-fpm.conf文件内容:
location ~* \.php$ {
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
7樓 巨大八爪鱼 2025-3-12 11:43

对于fedora41系统,php-fpm.conf里面的fastcgi_pass 127.0.0.1:9000;要改成
fastcgi_pass php-fpm;
另外再新建一个php-upstream.conf,内容如下:
upstream php-fpm {
        server unix:/run/php-fpm/www.sock;
}

 

/opt/nginx-1.27.4/conf/nginx.conf里面
顶部新加一句user nginx;
http块内,server块外的上方添加一句include /home/oct1158/config/nginx/php-upstream.conf;

这是因为fedora41系统的php-fpm服务不是用的9000端口,而是用的unix socket文件。

sudo systemctl start php-fpm
sudo systemctl enable php-fpm
sudo systemctl restart opt_nginx

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。