在centos安裝ssl并運行的方法:
通過安裝nginx來配置運行ssl,步驟如下:
1.安裝nginx,命令如:
sudo yum install epel-release
sudo yum install nginx
2.再輸入命令讓nginx隨系統啟動而啟動,命令如:
sudo systemctl enable nginx
3.打開nginx配置文件,在HTTP節點下配置兩個server節點,其他不變,例如:
server
{
listen 443;
server_name your-domain.com www.your-domain.com;
ssl on;
ssl_certificate /root/ssl/your-domain.crt;
ssl_certificate_key /root/ssl/your-domain.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_buffer_size 128k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
proxy_pass http://127.0.0.1:912;
}
}
server
{
listen 80;
server_name your-domain.com www.your-domain.com;
rewrite ^(.*)$ https://$host$1 permanent;
}