Przeglądaj źródła

修复ipv6环境ssl证书申请域名验证失败

183行,修改支持2-9位的长域名后缀,如 .store 等。
acme.sh申请ssl证书工具help里指明:
--listen-v4                       Force standalone/tls server to listen at ipv4.   
--listen-v6                       Force standalone/tls server to listen at ipv6.
以上参数,仅对standalone域名验证模式有效,对vhost.sh里面使用的dns、webroot域名验证方式无效。
Nginx官方文档提到:未指定listen指令时,超级用户权限下默认自动侦听 *:80,即IPv4的80端口,否则,默认自动侦听 *:8000,即ipv4的8000端口。Nginx并不会侦听ipv6地址。所以,域名解析使用了ipv6地址的证书申请无法通过域名验证,导致acme.sh证书申请失败。
所以,应该加上ipv6环境判断,并指定侦听ipv6的80端口。以上修复,实测有效。
goatlove 2 lat temu
rodzic
commit
b378592174
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      vhost.sh

+ 6 - 2
vhost.sh

@@ -180,7 +180,7 @@ If you enter '.', the field will be left blank.
       while :; do echo
         read -e -p "Please enter your email: " Email
         echo
-        if [[ $Email =~ ^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,4}$ ]]; then
+        if [[ $Email =~ ^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,9}$ ]]; then
           break
         else
           echo "${CWARNING}input error!${CEND}"
@@ -216,7 +216,11 @@ If you enter '.', the field will be left blank.
     else
       if [ "${nginx_ssl_flag}" == 'y' ]; then
         [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost
-        echo "server {  server_name ${domain}${moredomainame};  root ${vhostdir};  access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf
+        if [ -n "`ifconfig | grep inet6`" ]; then
+          echo "server {  listen 80;  listen [::]:80;  server_name ${domain}${moredomainame};  root ${vhostdir};  access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf
+        else
+          echo "server {  listen 80;  server_name ${domain}${moredomainame};  root ${vhostdir};  access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf
+        fi
         ${web_install_dir}/sbin/nginx -s reload
       fi
       if [ "${apache_ssl_flag}" == 'y' ]; then