VPS侦探论坛

 找回密码
 注册
查看: 4550|回复: 11

阿里云ECS,购买的1年的免费证书,LNMPA,如何配置HTTPS?

[复制链接]
发表于 2017-3-31 00:11:25 | 显示全部楼层 |阅读模式

按照阿里云官方的教程,安装后在域名前加HTTPS还是会显示“网站访问出错”。网上的各种教程也搜烂了,军哥在论坛上说是只要配置NGINX。折腾了几天,实在是不会弄。

所以恳请军哥发一个详细的完整的“LNMPA+阿里云ECS+阿里云免费证书”的亲测教程。有时候军哥说的太简略了,实在看不懂哦~~
相信急需这个教程的人也不在少数吧~~
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2017-3-31 00:17:05 | 显示全部楼层


我在阿里云官方提交了一个工单,客服说是 配置环境的问题,他们那边并没有禁用443端口。
而且客服还推荐购买 “云资源管理基础设置服务”,就是远程协助,200¥/次……
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2017-3-31 10:05:15 | 显示全部楼层

检查iptables,看443端口是否开了 https://www.vpser.net/security/linux-iptables.html
ps aux 看nginx是否允许,netstat -ntl 看443端口是否存在
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2017-3-31 13:14:30 | 显示全部楼层



输入netstat -ntl后:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:88            0.0.0.0:*               LISTEN     

443端口未开启
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2017-3-31 15:42:27 | 显示全部楼层

用iptables开放443端口看看,还有一个也要注意的,看看有没有开启阿里云的端口安全策略,有些是只开放22和80端口的。

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2017-3-31 17:56:40 | 显示全部楼层

输入 netstat -ntl,443端口已经打开了
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:88            0.0.0.0:*               LISTEN

阿里云官方提供的配置代码如下:
server {
    listen 443;
    server_name localhost;
    ssl on;
    root html;
    index index.html index.htm;
    ssl_certificate   cert/214055440470970.pem;
    ssl_certificate_key  cert/214055440470970.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 / {
        root html;
        index index.html index.htm;
    }
}
用这个代码的话,打开的是 Welcome to Nginx的欢迎页面。

如果改了倒数第二行的 root html,改为网站的根目录,就会出现403错误。

实在是弄不来啊~~
 楼主| 发表于 2017-3-31 17:57:29 | 显示全部楼层

iptables按照军哥的教程, 已经装上了,而且开启了443端口。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2017-3-31 18:03:35 | 显示全部楼层

阿里云官方的教程为:
1、下载证书for Nginx
2、安装证书:
文件说明:
1. 证书文件214055440470970.pem,包含两段内容,请不要删除任何一段内容。
2. 如果是证书系统创建的CSR,还包含:证书私钥文件214055440470970.key。
( 1 ) 在Nginx的安装目录下创建cert目录,并且将下载的全部文件拷贝到cert目录中。如果申请证书时是自己创建的CSR文件,请将对应的私钥文件放到cert目录下并且命名为214055440470970.key;
( 2 ) 打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件,找到:
# HTTPS server
# #server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
#
#
#}
#}
( 3 ) 将其修改为 (以下属性中ssl开头的属性与证书配置有直接关系,其它属性请结合自己的实际情况复制或调整) :
server {
    listen 443;
    server_name localhost;
    ssl on;
    root html;
    index index.html index.htm;
    ssl_certificate   cert/214055440470970.pem;
    ssl_certificate_key  cert/214055440470970.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 / {
        root html;
        index index.html index.htm;
    }
}
保存退出。
( 4 )重启 Nginx。
( 5 ) 通过 https 方式访问您的站点,测试站点证书的安装配置。如遇到证书不信任问题,请查看相关文档。

但是这个教程里,第二步,也就是:
( 2 ) 打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件,找到:
# HTTPS server
# #server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
#
#
#}
#}
这些代码找不到,所以只能新增。或者新建一个.conf的文件,把(3)里的代码粘进去。

我严格按照教程来的,443端口也开了,还是不行。。。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2017-3-31 20:51:40 | 显示全部楼层

lnmp 1.4的话可以使用lnmp ssl add 进行添加,也可以参考:https://www.vpser.net/build/letsencrypt-free-ssl.html 这个教程

也可以联系购买付费服务
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2017-3-31 22:50:25 | 显示全部楼层



好的,多谢军哥哦~~
 楼主| 发表于 2017-3-31 23:32:58 | 显示全部楼层

LNMPA更新至1.4,:
wget -c http://soft.vpser.net/lnmp/lnmp1.4beta.tar.gz && tar zxf lnmp1.4beta.tar.gz && cd lnmp1.4 && ./upgrade1.x-1.4.sh
然后使用lnmp ssl add 进行添加

添加后出现错误如下:
IMPORTANT NOTES:
- The following errors were reported by the server:

   Domain: uploads.xiaosala.com
   Type:   unauthorized
   Detail: Invalid response from
   http://uploads.xiaosala.com/.well-known/acme-challenge/r1tcr8MfeuUZQfBuegXlK0QuYxgTrQzS5R_0Rp03MQ0
   [220.243.236.183]: 404

   Domain: www.xiaosala.com
   Type:   unauthorized
   Detail: Invalid response from
   http://www.xiaosala.com/.well-known/acme-challenge/Kk25HrjsesJRg5HO-8rHi9wkWuhrqBSKy4s39XL7sA4:
   "<html>
   <head><title>403 Forbidden</title></head>
   <body bgcolor="white">
   <center><h1>403 Forbidden</h1></center>
   <hr><center>"

   Domain: xiaosala.com
   Type:   unauthorized
   Detail: Invalid response from
   http://xiaosala.com/.well-known/acme-challenge/3WDcL1bgCKP9Rm4QqAIr5a0YVor2lwaXqFhlrwbZcGA:
   "<html>
   <head><title>403 Forbidden</title></head>
   <body bgcolor="white">
   <center><h1>403 Forbidden</h1></center>
   <hr><center>"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address.
- Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
Let's Encrypt SSL Certificate create failed!

哎。。还是不弄了,等到儿童节1.4稳定版出来了,军哥应该会出一个专门的升级教程的,到时候再弄好了。

还有,想问下军哥,如果LNMPA1.3 配置 HTTPS的话,收费标准是多少呢?
发表于 2017-4-1 09:29:07 | 显示全部楼层

回复 11# 的帖子


以前早就说过了,升级后只能是新的虚拟主机,https://bbs.vpser.net/thread-14905-1-1.html 或自己修改配置文件

付费联系下方QQ或旺旺
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-27 12:17 , Processed in 0.028887 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表