• centos安装配置nginx,ssl生产和配置教程


    【一】nginx安装
    nginx安装带ssl扩展:

    cd /usr/local/src #进入用户目录
    wget http://nginx.org/download/nginx-1.15.0.tar.gz #下载最新版本nginx
    tar -zxvf nginx-1.15.0.tar.gz #解压
    cd nginx-1.15.0 #进入目录
    ./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module --with-http_image_filter_module #检测
    说明--prefix 指定安装目录
    make #编译
    make install #安装

    安装服务实现自启动:

    #vim /lib/systemd/system/nginx.service
    [Unit]
    Description=nginx
    After=network.target
    [Service]
    Type=forking
    ExecStart=/opt/nginx/sbin/nginx
    ExecReload=/opt/nginx/sbin/nginx -s reload
    ExecStop=/opt/nginx/sbin/nginx -s stop
    PrivateTmp=true
    [Install]

    WantedBy=multi-user.target
    #chmod 754 /lib/systemd/system/nginx.service
    #systemctl start nginx.service
    #systemctl enable nginx.service

    常用命令:启动nginx服务
    /opt/nginx/sbin/nginx
    常用命令:平滑重启nginx
    /opt/nginx/sbin/nginx -s reload

    【二】nginx配置ssl
    cd / #找到根目录
    find -name nginx.conf #查找nginx.conf的配置文件
    vi /opt/nginx/conf/nginx.conf

    upstream hello{
       server 127.0.0.1:3000;
    }
    server {
      listen 80;
      server_name ssl.22.cn;
      rewrite ^(.*)$ https://$host$1 permanent; #http强制跳转https
      #charset koi8-r;

      #access_log logs/host.access.log main;

      location / {
        proxy_pass http://hello; #代理
      }
    }
    # HTTPS server
    server {
      listen 443 ssl;
      server_name ssl.22.cn;
      ssl_certificate key/ssl.22.cn_ssl.crt; #证书
      ssl_certificate_key key/ssl.22.cn_ssl.key; #私钥
      ssl_session_cache shared:SSL:1m;
      ssl_session_timeout 5m;
      ssl_ciphers HIGH:!aNULL:!MD5;
      ssl_prefer_server_ciphers on;
      location / {
        proxy_pass http://hello;
      }
    }

    【三】如何生成证书?
    上 https://ssl.22.cn 申请个免费证书

  • 相关阅读:
    BZOJ3670:[NOI2014]动物园(KMP)
    415. [HAOI2009] 旅行
    U10223 Cx大帝远征埃及
    U10206 Cx的治疗
    2741. [济南集训 2017] 掰巧克力
    复习题目汇总 over
    7-20 表达式转换(25 分)
    7-19 求链式线性表的倒数第K项(20 分)(单链表定义与尾插法)
    7-18 银行业务队列简单模拟(25 分)
    7-17 汉诺塔的非递归实现(25 分)(有待改进)
  • 原文地址:https://www.cnblogs.com/kobewang/p/9469870.html
Copyright © 2020-2023  润新知