Nginx配置https

2018-01-31  本文已影响7人  8813d76fee36

上传https证书

$ cd /etc/nginx/

$ mkdir certs

$ scp xxx.crt xxx.pem user@host:/etc/nginx/certs/

修改Nginx配置

# HTTPS server
  server {
        listen 443;
        server_name dev.wj.cn;
        ssl on;
        ssl_certificate /etc/nginx/certs/1_dev.wj.cn_bundle.crt;
        ssl_certificate_key /etc/nginx/certs/2_dev.wj.cn.key;
        ssl_session_timeout 10m;
        ssl_protocols SSLv2 SSLv3 TLSv1;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers on;
  }   

$ nginx -s reload

开启防火墙443端口监听

$ firewall-cmd --zone=public --list-ports

$ firewall-cmd --add-port=443/tcp --permanent

--permanent参数表示永久生效

$ firewall-cmd --reload

可选配置

http强制跳转https

return 301 https://$server_name$request_uri;

http强制跳转https

将http server中的转发配置移动到https server

最终配置文件效果

最终效果
上一篇下一篇

猜你喜欢

热点阅读