pm2管理多个nodejs项目nginx反向代理多域名https协议ssl证书

简介: pm2管理多个nodejs项目nginx反向代理多域名https协议ssl证书

1565591661627
1565591760930
首先下载免费证书,上传至服务器,证书有很多种,以上阿里云免费版
证书分为DV、OV、EV三种:
DV SSL证书:亦是域名验证型证书,申请该证书时,CA(证书颁发机构)只需审核域名的所有权即可,整个流程非常简单,无需人工,由系统自动完成。所以时间上是比较快的,一般10分钟左右就能签发,而且价格比较便宜,相对来说等级也是比较低的,适合个人网站及小型组织或企业网站。
OV SSL证书:这个是企业验证型,比DV证书的验证要求要高一些。它不仅需要验证域名的所有权,还需要验证企业身份,验证是需提供企业信息和公司营业执照扫描件等资料,都是通过人工审核的,一般需要3-5个工作日才能颁发,价格也相对较高一些,但是安全等级大大的提高了,适合一般组织或中小型企业网站。
EV SSL证书:这是目前业界最高安全级别的证书,功能比前两位都强大。如果用户安装了此证书,浏览器不仅会显示绿色的地址栏及https前缀和安全锁的标志,而且还会显示企业名,这个不仅看上去就很高大上,而且真的更安全。当然了,EV SSL证书审核也是最严格的,需要提供企业信息和公司营业执照扫描件等资料以及邓白氏或者律师意见信,CA机构会人工验证组织和电话信息,一般3-7个工作日才能颁发,价格也是相对比较高的,适用于在线交易网站、大型企业或金融、银行等组织。

以上三种证书都可选单域名,多域名,通用域名3个种类,价格也不同。
单域名:仅保护一个域名的普通SSL证书。

www.centby.com
AI 代码解读

多域名:可以同时保护多个域名数量可选择,不管是主域名还是子域名都行。

www.centby.com,m.centby.com,porcelain.bbs.centby.com
AI 代码解读

通用域名:能够保护一个域名以及该域名的所有下一级域名,有范围的限制,但是没有数量的限制。

*.centby.com 或 *.info.centby.com 不可以越级
AI 代码解读

配置Nginx

vi /usr/local/nginx/conf/nginx.conf
AI 代码解读
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

#start

    upstream demoa {
       #ip_hash;
       server 127.0.0.1:8000;
    }
    upstream demob {
       #ip_hash;
       server 127.0.0.1:8001;
    }

#end

#start ssl

    server {
        listen       443;
        server_name  www.centby.com;
        ssl on;
        root         /usr/share/nginx/html;

        ssl_certificate "cert/cert-15_xy.centby.com.crt";##示例
        ssl_certificate_key "cert/cert-15_xy.centby.com.key";##示例
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_prefer_server_ciphers on;

        location / {
            proxy_pass http://demoa;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

    server {
        listen       443;
        server_name  m.centby.com;
        ssl on;
        root         /usr/share/nginx/html;

        ssl_certificate "cert/cert-8_aapi.crt";##示例
        ssl_certificate_key "cert/cert-8_bapi.key";##示例
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_prefer_server_ciphers on;

        location / {
            proxy_pass http://demob;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

#end ssl

    server {
        listen       80;
        server_name  www.centby.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        #location / {
        #    root   html;
        #     index  index.html index.htm;
        # }

        location / {
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_buffering off;
             proxy_pass http://demoa;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

   server {
        listen       80;
        server_name  m.centby.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        #location / {
        #    root   html;
        #     index  index.html index.htm;
        # }

        location / {
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_buffering off;
             proxy_pass http://demob;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    #include vhost/*.conf;

}
AI 代码解读

重启Nginx服务

//进入目录
cd /usr/local/nginx/sbin
//测试
./nginx -t
//重启服务
./nginx -s reload
AI 代码解读
佀无极
+关注
目录
打赏
0
0
0
0
250
分享
相关文章
node反向代理,解决跨域(http-proxy-middleware)
使用node.js和http-proxy-middleware库实现反向代理,解决跨域问题,允许前端请求通过代理访问不同端口的服务。
279 3
本地通过域名访问虚拟机上nginx的服务、搭建域名访问环境一(反向代理配置)
这篇文章介绍了如何通过域名在本地访问虚拟机上的nginx服务,包括创建nginx容器、修改配置文件、修改本地host文件以及进行访问测试的详细步骤。文章提供了具体的Docker命令来创建并配置nginx容器,展示了配置文件的修改示例,说明了如何在本地系统的hosts文件中添加虚拟机IP和自定义域名,以及如何通过浏览器进行测试访问。
本地通过域名访问虚拟机上nginx的服务、搭建域名访问环境一(反向代理配置)
【Azure 应用服务】Azure App Service For Linux 上实现 Python Flask Web Socket 项目 Http/Https
【Azure 应用服务】Azure App Service For Linux 上实现 Python Flask Web Socket 项目 Http/Https
Nginx——一个域名下部署多个Vue项目
如何在同一域名下部署第二个Vue项目而不影响现有项目:更新`vue.config.js`,设置`publicPath`为`/screen/`。修改Vue Router的`base`为`screen`。在Nginx配置中添加新location `/screen`,指向第二项目`dist`目录。测试访问`http://<域名>/screen/`。别忘了检查并修复任何遗漏的配置,如数据看板默认设置。
418 2
MAC如何使用Git命令行上传本地项目及理解,failed to push some refs to ‘https://gitee.com/brother-barking/spxx.git
MAC如何使用Git命令行上传本地项目及理解,failed to push some refs to ‘https://gitee.com/brother-barking/spxx.git
基于nginx反向代理实现OSS固定域名IP访问
本文基于阿里云OSS手册:https://help.aliyun.com/zh/oss/use-cases/use-an-ecs-instance-that-runs-centos-to-configure-a-reverse-proxy-for-access-to-oss,继续深入讨论如何利用nginx反向代理,实现固定的IP/域名访问OSS bucket。官方文档能够解决大部分的反向代理固定IP访问oss bucket的场景,但是对于必须使用域名作为endpoint的系统,会出现signatrue鉴权问题。本文继续在官方文档的基础上,将反向代理需要域名作为endpoint的场景补齐方案。
阿里云SSL证书不同类型DV、OV和EV如何收费?单域名和通配符SSL价格整理
阿里云SSL证书提供免费和收费版本,涵盖DV、OV、EV多种类型。收费证书品牌包括DigiCert、GlobalSign等,价格从238元/年起。免费SSL证书由Digicert提供,单域名有效3个月,每个实名主体每年可领取20个。具体价格和详情见阿里云SSL官方页面。
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等