700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > nginx配置http https访问 nginx指定ssl证书 阿里云腾讯云华为云设置nginx https安全访问

nginx配置http https访问 nginx指定ssl证书 阿里云腾讯云华为云设置nginx https安全访问

时间:2019-07-22 05:55:57

相关推荐

nginx配置http https访问 nginx指定ssl证书 阿里云腾讯云华为云设置nginx https安全访问

nginx配置http、https访问

要设置https访问需要从对应的云厂商申请证书,并下载Nginx证书到服务器。

我这里从阿里云申请了免费的域名证书,然后将证书放置在服务器的/etc/ssl/.com/路径下,开始配置

这里直接上server节点,放在你的nginx.conf文件中(覆盖也可以)

server {# http 监听80端口listen 80 default_server;listen [::]:80 default_server;server_name _;root /usr/share/nginx/html;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;# 域名根路径直接访问的路径location / {root /opt/website/;index index.html index.htm;}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}}# 设置https访问则多添加一个server节点server{#监听443端口listen 443;#对应的域名,把改成自己的域名就可以了server_name ;ssl on;#从云厂商获取到的第一个文件的全路径ssl_certificate /etc/ssl/.com/.pem;#从云厂商获取到的key文件路径ssl_certificate_key /etc/ssl/.com/.key;ssl_session_timeout 5m;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;ssl_prefer_server_ciphers on;#这是我的主页访问地址,因为使用的是静态的html网页,所以直接使用location就可以完成了。location / {root /opt/website/;index index.html index.htm;}}

配置好后使用 systemctl restart nginx重启即可,直接使用https访问一下试试吧!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。