本次操作全部是在Centos系統上,window系統可能會有些差别
環境安裝指南,如安裝可跳過這段
、yum install -y nodejs
、npm install -g cnpm --registry=https://registry.npm.taobao.org
、cnpm install -g sails
、yum -y install gcc automake autoconf libtool make
、yum install gcc gcc-c++
、yum install pcre pcre-devel
、yum install zlib zlib-devel
、yum install openssl openssl-devel
、wget http://nginx.org/download/nginx-1.12.1.tar.gz
//下載下傳并解壓Nginx
gzip -d nginx-.tar.gz
tar xvf nginx-.tar
cd nginx-/
//進入目錄,執行configure
、./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
、make&&make install
cd /usr/local/nginx/conf/
在conf檔案夾下,分别建立cert和vhosts檔案夾
cert存放SSL證書
vhosts存放反向代理配置檔案
在vhosts檔案夾下,建立配置檔案 my.conf
server {
listen ;
server_name www.mysite.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen ssl;
server_name www.mysite.com;
ssl_certificate cert/pem;
ssl_certificate_key cert/key;
ssl_session_timeout m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1 TLSv1;
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 m;
}
}
修改配置檔案 nginx.conf
http 标簽下面添加,
include vhosts/*;//引用反向代理配置檔案
nginx -c /usr/local/nginx/conf/nginx.conf 重新開機nginx
nginx -s reload 重新開機配置
重新開機nginx即可