本次操作全部是在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即可