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;
}
相关推荐
fengyehongWorld4 小时前
Linux yq命令
linux·运维·服务器
weixin_404679314 小时前
docker部署ollama
运维·docker·容器
chenjingming6664 小时前
浏览器(如chrome)代理抓包时提示Your Connection is not private 问题临时处理
chrome·https
草莓熊Lotso4 小时前
Qt 主窗口核心组件实战:菜单栏、工具栏、状态栏、浮动窗口全攻略
运维·开发语言·人工智能·python·qt·ui
RisunJan4 小时前
Linux命令-lprm(删除打印队列中任务)
linux·运维·服务器
Web极客码4 小时前
WordPress从经典编辑器升级到古腾堡编辑器
运维·编辑器·wordpress
zzzsde4 小时前
【Linux】进程(5):命令行参数和环境变量
linux·运维·服务器
迎仔4 小时前
E-自动化:GPU驱动维护自动化
运维·gpu·gpu驱动
草莓熊Lotso5 小时前
Linux 文件描述符与重定向实战:从原理到 minishell 实现
android·linux·运维·服务器·数据库·c++·人工智能
历程里程碑5 小时前
Linux22 文件系统
linux·运维·c语言·开发语言·数据结构·c++·算法