• nginx配置https域名


                    nginx安装配置支持https和配置https域名

    1 yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
    1、安装依赖
    1 wget http://nginx.org/download/nginx-1.10.2.tar.gz
    2 tar -zxvf  nginx-1.10.2.tar.gz
    3 cd nginx-1.10.2/
    2、下载nginx

    3、配置nginx

      

    ./configure
     1 ./configure 
     2 --prefix=/usr/local/nginx 
     3 --conf-path=/usr/local/nginx/conf/nginx.conf 
     4 --pid-path=/usr/local/nginx/conf/nginx.pid 
     5 --lock-path=/var/lock/nginx.lock 
     6 --error-log-path=/var/log/nginx/error.log 
     7 --http-log-path=/var/log/nginx/access.log 
     8 --with-http_gzip_static_module 
     9 --http-client-body-temp-path=/var/temp/nginx/client 
    10 --http-proxy-temp-path=/var/temp/nginx/proxy 
    11 --http-fastcgi-temp-path=/var/temp/nginx/fastcgi 
    12 --http-uwsgi-temp-path=/var/temp/nginx/uwsgi 
    13 --http-scgi-temp-path=/var/temp/nginx/scgi
    3.2、自定义配置
    1 ./configure --prefix=/usr/local/nginx --with-http_ssl_module
    3.3、支持HTTPS
    make
    1 /usr/local/nginx/sbin/nginx -V
    查看nginx是否支持
    1 ./configure --with-http_ssl_module
    2 make
    如果没支持才编译一下
     1 # 以下属性中以ssl开头的属性代表与证书配置有关,其他属性请根据自己的需要进行配置。
     2 server {
     3 listen 443 ssl;   #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
     4 server_name localhost;  #将localhost修改为您证书绑定的域名,例如:www.example.com。
     5 root html;
     6 index index.html index.htm;
     7 ssl_certificate cert/domain name.pem;   #将domain name.pem替换成您证书的文件名。
     8 ssl_certificate_key cert/domain name.key;   #将domain name.key替换成您证书的密钥文件名。
     9 ssl_session_timeout 5m;
    10 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  #使用此加密套件。
    11 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   #使用该协议进行配置。
    12 ssl_prefer_server_ciphers on;   
    13 location / {
    14 root html;   #站点目录。
    15 index index.html index.htm;   
    16 }
    17 }
    按照下文中注释内容修改nginx.conf文件:
    1 server {
    2  listen 80;
    3  server_name localhost;   #将localhost修改为您证书绑定的域名,例如:www.example.com。
    4 rewrite ^(.*)$ https://$host$1 permanent;   #将所有http请求通过rewrite重定向到https。
    5  location / {
    6 index index.html index.htm;
    7 }
    8 }
    可选: 设置HTTP请求自动跳转HTTPS。

    本博文参考https://blog.csdn.net/long690276759/article/details/82790002和阿里云官方文档https://yundunnext.console.aliyun.com/?spm=5176.12818093.network-security.dbuy.488716d0rd77Sk&p=cas#/overview/cn-hangzhou 来写出

  • 相关阅读:
    最全的常用正则表达式大全
    服务器调用JS
    ASP-----分页功能的实现
    流操作text文件------读取、保存文档
    linq to sql 增删改查
    数据库的高级应用
    SQL---------表的约束
    面向对象--继承练习
    Winform---文件夹操作
    面向对象--里氏转换练习
  • 原文地址:https://www.cnblogs.com/guanzhuang/p/12221543.html
Copyright © 2020-2023  润新知