nginx配置HTTPS请求遇到的错误

配置http重定向https需要1.修改配置文件2.添加所需要的依赖模块3.请求时配置

注意:
一个是nginx的配置,你改proxy_pass 有空格或者是其他特殊字符导致报错了
加了proxy_pass 访问https://carlife.aimbotss.cn/ 等于访问 http://47.103.129.164:8080

问题记录:
小程序后台-开发-开发设置-服务器域名

1.添加所需要的依赖模块查看 nginx 是否安装 http_ssl_module 模块,编译nginx,添加模块

使用nginx -V大写的V查看所需要的依赖模块

# 查看版本与编译参数,就是下面结果中的configure arguments:后面的参数,后面重新编译时需要带上
nginx -V

在这里插入图片描述下载相同版本nginx

# 官网下载nginx-1.14.1 并解压
$ wget http://nginx.org/download/nginx-1.14.1.tar.gz
$ tar -zxvf nginx-1.14.1.tar.gz

备份原有nginx和配置

# 暂时备份到用户目录下,以备操作错误时,进行还原
$ cp /usr/sbin/nginx ~/nginx.back
$ cp -r /ect/nginx ~/nginx.conf.back
# 安装编译的依赖包
yum install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-dev libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data gperftools redhat-rpm-config
 
# 进入nginx,进行编译,编译时需要将上面查看到的现有nginx的参数都带上,然后在最后面添加你需要新增的模块
$ cd nginx-1.14.1
 
# 因为这里我示例添加第三方模块nginx-auth-ldap,需要安装openldap-devel
$ yum install openldap-devel -y
 
# 其中最后的--add-module=为我这里示例的需要增加的第三方模块的存放路径,第三方模块需要提前下载好
# 不管是第三方模块,还是自身模块,都直接在最后添加参数即可。
$ ./configure --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-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --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' --add-module=/root/nginx-auth-ldap

# 编译,注意:这里很多说不能make install,只make就好了,其实不然,
# 在执行./configure命令时则已经查出了原有nginx的各个文件的路径,如果原来没有nginx,则会默认安装到/usr/local/nginx目录下。
# 直接执行make install 则会自动替换原来的nginx,无须手动,也不会中断nginx进程。
$ make && make install

检查新nginx,重启生效

# 编译后,会自动替换原有nginx,查看nginx配置,是否还是之前的,查看conf.d内的配置是否还在
$ cat /etc/nginx/nginx.conf 
$ ls /etc/nginx/conf.d
 
# 查看nginx参数,看看我们新增的模块在不在
$ nginx -V
 
# 重启nginx生效
$ systemctl restart nginx

安装openssl

yum -y install openssl openssl-devel

tlsv1.2是否生效,打开谷歌浏览器访问, 按F12,点击security, 如果出现下面的提示说明开启了tlsv1.2,否则不行。
在这里插入图片描述

收到the “ssl” parameter requires
ngx_http_ssl_module报错:您需要重新编译Nginx并在编译安装的时候加上–with-http_ssl_module配置。

收到"/cert/3970497_pic.certificatestests.com.pem":BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or
directory:fopen(’/cert/3970497_pic.certificatestests.com.pem’,‘r’)
error:2006D080:BIO routines:BIO_new_file:no such
file)报错:您需要去掉证书相对路径最前面的/。例如,您需要去掉/cert/cert-file-name.pem最前面的/,使用正确的相对路径cert/cert-file-name.pem。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一时学习一时爽,一直学习一直爽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值