主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情! |
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作 |
HTTPS协议的主要特点可以分为两类。 一是建立信息安全通道,保证数据传输的安全。 另一件要做的事情是检查网站的真实性。 您可以根据您的独特需求选择购买 SSL 证书。 接下来,在我们的SSL证书申请指南中,我们将分享一个使用Nginx设置https服务器的教程。
1.创建SSL证书
1.1生成私钥。 openssl genrsa -des3 -out xn2.lqb.com.key 2048。 此命令使用 DES3 算法生成 2048 位 RSA 私钥。 您可以任意命名私钥文件。 只需在 Nginx 配置中指定文件路径即可。 系统将要求您为您的私钥设置密码。 设置密码并记住它。
[root@Monitorssl]#opensslgenrsa-des3-outxn2.lqb.com2048RSA私钥,2048位长模数生成……………………………….+++………… … …………… ….+++ eis65537(0x010001) 请输入您的 xn2.lqb.com 密码: verifying-Enterpassphraseforxn2.lqb.com:
1.2 中生成的密钥带有密码。 如果要删除密码,请运行以下命令 openssl rsa -in xn2.lqb.com -out xn2.lqb.com_nopwd。 键
[root@Monitorssl]#ls xn2.lqb.com [root@Monitorssl]#opensslrsa-inxn2.lqb.com-outxn2.lqb.com_nopwd.key Enterpassphraseforxn2.lqb.com:writingRSAkey
1.3 生成私钥的证书请求 生成文件企业社会责任。 openssl rsa -in xn2.lqb.com -out xn2.lqb.com_nopwd.key
[root@Monitorssl]#opensslrsa-inxn2.lqb.com-outxn2.lqb.com_nopwd.key of xn2.lqb输入您的密码。 com:写入 RSAkey [root@Monitorssl]#opensslreq-new-keyxn2.lqb.com-outxn2.lqb.com.csr 输入 xn2.lqb.com 的密码:系统会提示您输入将包含在证书请求中的信息马苏。 您将要输入的内容称为专有名称或 DN。 有多个字段,但您可以将某些字段留空。 某些字段有默认值;如果您输入“.”,该字段将保持空白。 —– 国家名称(2 个字母代码)[AU]:CN 州或州名称(全名)[某些州]:s杭州 LocalityName(示例:城市)[]:shanghai 组织名称(示例:公司)[InternetWidgitsPtyLtd]:xn2.lqb.com OrganizationalUnitName(示例:部分)[]:IT CommonName(示例:serverFQDNorYOURname)[]:xn2.lqb.com邮箱地址[]:2223344@qq.com 请输入以下要与您的证书请求一起发送的“附加”属性。 Achallengepassword[]:可选的公司名称[]:[root@Monitorssl]#ls xn2.lqb.comxn2.lqb.com.csrxn2.lqb.com_nopwd.key
1.4。 要形成证书,证书请求文件中的 CSR 文件必须由 CA 签名。 你可以把这个CSR发送到StartSSL(免费),Verisign(昂贵),以及其他经过他验证的地方。 您也可以自己成为CA并为自己颁发证书。 创建自签名 CA 证书。 openssl req -new -x509 -days 3650 -key xn2.lqb.com -out xn2.lqb.com.crt
[root@Monitorssl]#opensslreq-new-x509-days3650-keyxn2.lqb。 com-outxn2.lqb.com.crt xn2.lqb.comxn2.lqb.com.csrxn2.lqb.com_nopwd.key [root@Monitorssl]#opensslreq-new-x509-days3650-keyxn2.lqb.com_nopwd.key-outxn2.lqb.com.crt 系统将提示您输入将包含在证书请求中的信息。 您将要输入的内容称为专有名称或 DN。 有多个字段,但您可以将某些字段留空。 某些字段有默认值,如果您输入“.”,该字段将保留为空。 —– 国家名称(两个字母代码)[AU]:CN StateorProvinceName(全名)[Some-State]:上海地区名称(例如城市)[]:上海 组织名称(例如公司)[InternetWidgitsPtyLtd]:lqb .com 组织单位名称(例如:部分))[]:it CommonName(例如 serverFQDN 或 YOURname)[]:xn2.lqb.com EmailAddress[]: [root@Monitorssl]#ls xn2.lqb.comxn2.lqb.com.crtxn2.lqb.com.csrxn2.lqb.com_nopwd.key
2. 配置nginx虚拟主机文件
[root@Monitorssl]# vim../server.conf 服务器{ Listen80;_namexn2.lqb.com; #rewrite^/(.*)$https:xn3.lqb.com/$1permanent; 位置/{indexindex.html; #proxy_cache_valid2003h; #proxy_cache_validall1m; ; #proxy_cache_use_staleerrortimeouthttp_500http_502http_503; #proxy_passhttp://192.168.180.9; #proxy_set_headerHost$host; #proxy_set_headerX-Real-IP$remote_addr; } location/images/ {indexindex.html; 服务器名称 xn2.lqb.com; sslon;### 为虚拟主机启用 SSL 支持 ssl_certificate/usr/local/nginx/conf/server/ssl/xn2.lqb.com.crt;###虚拟主机 ssl_certificate_key 指定签名证书文件位于/usr/ local/nginx/conf/server/ssl/xn2.lqb.com_nopwd.key;###指定虚拟服务器私钥文件。 host##ssl_session_timeout5m;####客户端可以复用缓存中保存的私钥文件会话参数时间 root/html/xn3; 位置/images/{indexindex.html;}位置/{ proxy_passhttp://192.168.180.23;y_set_headerHost$host; proxy_set_headerX-真实IP$remote_addr;
这几篇文章你可能也喜欢:
- 虚拟主机网站配置SSL证书教程(虚拟主机SSL证书安装教程)
- CPanel控制面板网站安装SSL证书教程(许可证管理)
- Microsoft Exchange 2013 安装和配置 SSL 证书教程
- 如何在Windows上部署SSL证书(SSL证书安装指南)
- Apache 配置 https 支持 SSL 教程(Apache 配置 https)
本文由主机参考刊发,转载请注明:使用 Nginx 设置 https 服务器的教程(nginx 设置) https://zhujicankao.com/141321.html
评论前必须登录!
注册