sails.js + nginx + https加密 + 反向代理

本次操作全部是在Centos系统上,window系统可能会有些差别
环境安装指南,如安装可跳过这段

1、yum install -y nodejs
2、npm install -g cnpm --registry=https://registry.npm.taobao.org
3、cnpm install -g sails
4、yum -y install gcc automake autoconf libtool make
5、yum install gcc gcc-c++
6、yum install pcre pcre-devel
7、yum install zlib zlib-devel
8、yum install openssl openssl-devel
9、wget http://nginx.org/download/nginx-1.12.1.tar.gz  
    //下载并解压Nginx
    gzip -d nginx-1.12.1.tar.gz
    tar xvf nginx-1.12.1.tar
    cd nginx-1.12.1/ 
    //进入目录,执行configure
10./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
11、make&&make install

cd /usr/local/nginx/conf/
在conf文件夹下,分别创建cert和vhosts文件夹
cert存放SSL证书
vhosts存放反向代理配置文件
在vhosts文件夹下,创建配置文件 my.conf

server {
    listen 80;
    server_name www.mysite.com;
    rewrite ^(.*) https://$server_name$1 permanent;
}
server {
        listen 443 ssl;
        server_name www.mysite.com;
        ssl_certificate   cert/214098802690.pem;
        ssl_certificate_key  cert/214098802690.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        location / {
            proxy_pass http://localhost:81;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size 1000m;
        }
}

修改配置文件 nginx.conf
http 标签下面添加,
include vhosts/*;//引用反向代理配置文件

nginx -c /usr/local/nginx/conf/nginx.conf 重启nginx
nginx -s reload   重启配置

重启nginx即可

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值