原因也很简单,nginx缺少http_ssl_module模块,编译安装的时候带上--with-http_ssl_module配置就行了,但是现在的情况是我的nginx已经安装过了,怎么添加模块,其实也很简单,往下看: 做个说明:我的nginx的安装目录是/usr/local/nginx这个目录,我的源码包在/usr/local/src/nginx-1.6.2目录
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:37
查看nginx原有的模块
/usr/local/mysoft/nginx-1.18.0/sbin/nginx -V
在configure arguments:后面显示的原有的configure参数如下:
--prefix=/usr/local/mysoft/nginx-1.18.0 --with-http_stub_status_module
那么我们的新配置信息就应该这样写:
./configure --prefix=/usr/local/mysoft/nginx-1.18.0 --with-http_stub_status_module --with-http_ssl_module
运行上面的命令即可,等配置完
配置完成后,运行命令
make
这里不要进行make install,否则就是覆盖安装
然后启动nginx,仍可以通过命令查看是否已经加入成功
/usr/local/mysoft/nginx-1.18.0/sbin/nginx -V
然后找到nginx安装目录,并配置nginx.conf文件,配置如下
- user root;
- worker_processes 1;
-
- events {
- worker_connections 1024;
- }
-
-
- http {
- include mime.types;
- default_type application/octet-stream;
-
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- #api负载均衡配置
- upstream apiServer {
- server 127.0.0.1:8081;
- server 127.0.0.1:8082;
- }
- #api服务1配置
- server {
- listen 443 ssl;
- server_name abc.com; #域名
- ssl_certificate cert/8588597_abc.com.pem; #证书地址目录 这里在把cert文件夹放在conf下
- ssl_certificate_key cert/8588597_abc.com.key;#证书 这里在把cert文件夹放在conf下
- ssl_session_timeout 5m;
- ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
- #表示使用的加密套件的类型。
- ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; #表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
- ssl_prefer_server_ciphers on;
-
- location / {
- proxy_pass http://apiServer;
- }
-
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- }
-
- #前端服务配置
- server {
- listen 80; #端口
- server_name www.abc123.com; #域名
- #www.abc123.com/admin 跳转下面服务
- location /admin {
- alias /home/java/admin-ui; #前端2代码的目录
- index index.html index.htm;
- }
-
- #www.abc123.com 跳转下面服务
- location / {
- alias /home/java/guang-wang/; #前端1代码的目录
- index index.html index.htm;
- }
- }
-
- }