Nginx 基础应用实战 04 在公网配置配置HTTPS

Nginx 基础应用实战 04

在公网配置配置HTTPS

Nginx配置

复制代码
     server {
             listen       443 ssl;
             server_name  aa.abc.com;

             ssl_certificate      /data/cert/server.crt;
             ssl_certificate_key  /data/cert/server.key;

     }

免费签名

https://freessl.cn

阿里云

腾讯云

Nginx配置

复制代码
server {
    #SSL 访问端口号为 443
    listen 443 ssl;
 #填写绑定证书的域名
    server_name duozuiyu.com;
 #证书文件名称
    ssl_certificate duozuiyu.com.crt;
 #私钥文件名称
    ssl_certificate_key duozuiyu.com.key;
    location / {
    #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
        root html;
        index  index.html index.htm;
    }
}

编译时报错

复制代码
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:98
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

解决方法:

  1. 重新编译 增加ssl模块

    ./configure --with-http_stub_status_module --with-http_ssl_module

  2. 执行 make

​ make执行完之后 不要执行install

  1. 备份
  2. 替换文件
  3. 启动Nginx
  4. 访问https

java项目的负载均衡

反向代理java项目

1.安装jdk

复制代码
yum install java-1.8.0-openjdk

2.上传项目

3.让https反向代理到本机Tomcat

复制代码
proxy_pass http://127.0.0.1:8080;

4.负载均衡

复制代码
  upstream httpd {
    server 192.168.43.152:80;
    server 192.168.43.153:80;
}
相关推荐
小同志007 小时前
⽹络原理-HTTP/HTTPS(一)
网络协议·http·https
DeeplyMind7 小时前
第12章 Docker存储机制(重要)
运维·docker·容器
鸠摩智首席音效师8 小时前
如何在 Linux 中将文件复制到多个目录 ?
linux·运维·服务器
香蕉你个不拿拿^8 小时前
Linux进程地址空间解析
linux·运维·服务器
人间打气筒(Ada)9 小时前
Linux学习~日志文件参考
linux·运维·服务器·学习·日志·log·问题修复
OpsEye10 小时前
交换分区优化实战:从监控到调优,让系统告别卡顿
运维·it·监控·告警·swap·监控系统·交换分区
大熊程序猿10 小时前
metabase 报表使用
运维
feichang_notlike311 小时前
Windows (WSL2) 搭建 openclaw
运维
❀͜͡傀儡师11 小时前
Spring Boot Pf4j模块化能力设计思考
运维·spring boot·后端·pf4j
石油人单挑所有12 小时前
ProtoBuf编写网络版本通讯录时遇到问题及解决方案
运维·服务器