一、https配置
cd到目录
#cd /usr/local/nginx/conf
创建服务器私钥
#openssl genrsa -des3 -out server.key 1024
签名请求的证书
#openssl req -new -key server.key -out server.csr
注意此步骤过程中需要填写一系列的东西(公司名称、所在地等按照实际情况填)
尤其注意 your server' hostname的填写,如果没有域名就直接填ip,如果有域名就填域名(都不需要端口号)
例如:
直接填ip: 61.155.86.78
域名: api.trewanyg.com
模糊域名: * .trewanyg.com
制作解密后的私钥 #openssl rsa -in server.key -out server_nopwd.key #openssl x509 -req -days 3650 -in server.csr -signkey server_nopwd.key -out server.crt
配置conf
server {
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server_nopwd.key;
}
启动nginx,ok
二、本地跨域转发
443端口
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate c:\server.crt;
ssl_certificate_key c:\server_nopwd.key;
location ^~ /abc/
{
proxy_pass https://api.abc.com;
root html\myweb;
index index.html index.htm;
}
}