步骤一:生成网站所使用的私钥和公钥
# cd /etc/nginx/certs/
# openssl genrsa > cert.key
# openssl req -new -x509 -key cert.key > cert.crt
步骤二:修改 Nginx 的配置文件
# vim /etc/nginx/nginx.conf
将部分内容修改如下:
......
upstream backend {
server backendserver1.example.com:443
server backendserver2.example.com:443
}
......
server {
listen 443;
server_name www.mydomain.com:443;
ssl on;
ssl_certificate /etc/nginx/certs/cert.crt;
ssl_certificate_key /etc/nginx/certs/cert.key;
location / {
proxy_pass http://backend;
}
.....
}