使用Nginx部署https服务

1. 下载Nginx服务

shell 复制代码
# centos
yum install -y nginx
# ubuntu
apt-get install -y nginx

2. 验证访问Nginx是否部署成功

http://192.168.20.11/

3. 生成SSL自签证书

python 复制代码
openssl req -x509 -newkey rsa:2048 -nodes -keyout my-nrdstudio.key -out my-nrdstudio.crt -days 365

4. index目录和证书

5. 增加Nginx配置文件

nginx 复制代码
server {
    listen 80;
    server_name hu123.cn www.hu123.cn 192.168.20.11;

    location ~/ {
        rewrite ^(.*)$ https://$host$1 permanent;  # http强制跳转https
    }
}

server {
    listen    443 ssl; 
    server_name  hu123.cn www.hu123.cn 192.168.20.11;
    root /opt/www/web/;

    ssl_certificate       /opt/www/my-nrdstudio.crt;
    ssl_certificate_key /opt/www/my-nrdstudio.key;         #证书密钥文件
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL;
}

5. 验证 http://hu123.cn https://hu123.cn 正常打开

相关推荐
geekrabbit2 小时前
机器学习和深度学习的区别
运维·人工智能·深度学习·机器学习·浪浪云
楠神说软件测试3 小时前
接口自动化框架入门(requests+pytest)
运维·数据库·自动化
学习3人组3 小时前
克隆centos网卡uuid相同如何修改
linux·运维·centos
小ᶻᶻᶻᶻᶻ4 小时前
DevOps工程师的职业发展路径
运维·devops
ZhangTao_zata4 小时前
ubuntu安装wordpress(基于LNMP环境)
linux·运维·ubuntu
不惑_5 小时前
Logstash 安装与部署(无坑版)
运维·jenkins
自律的kkk5 小时前
docker配置镜像加速器
运维·docker·容器
繁依Fanyi6 小时前
828 华为云征文|华为 Flexus 云服务器部署 RustDesk Server,打造自己的远程桌面服务器
运维·服务器·开发语言·人工智能·pytorch·华为·华为云
优思学院6 小时前
优思学院|如何从零开始自己学习六西格玛?
大数据·运维·服务器·学习·六西格玛黑带·cssbb
Flying_Fish_roe6 小时前
linux-软件包管理-包管理工具(RedHat/CentOS 系)
linux·运维·centos