一、nginx.conf文件配置
server {
listen 80;
server_name 域名地址; # 你的域名地址
#rewrite ^(.*)$ https://${server_name}$1 permanent;
location /{
proxy_pass http://127.0.0.1:6677/; #你的项目地址
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection $connection_upgrade;
}
}
#部署SSL证书HTTPS访问
server {
listen 443 ssl;
server_name 你的域名地址;#你的域名地址
#ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/你的pem证书.pem; ##此处的cert为conf文件下新建的cert文件专门用作存放证书文件
ssl_certificate_key cert/你的key证书.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 / {
# root html;
# index index.html index.htm;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:6677; #你的项目地址
proxy_redirect default;
proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection $connection_upgrade;
}
}
说明: cert文件为放置证书的文件,位置位于nginx软件的conf文件夹下
总结
配置好项目代理地址,再向阿里云或者腾讯云申请SSL证书,下载之后放到指定的文件夹下,配置SSL访问