asme.sh with DNS Alias Mode

由于 Godaddy 停止了免费的支持ACME SSL 证书签发(DNS 模式),

不得不改用 DNS Alias 模式, 让阿里云 为Godaddy 管理的域名,代理合作签发SSL证书

默认的机构,ZEROSSL,一个初创企业,早已超负荷运转,多数时间已经无法正常签发了。改用Google的证书机构,相对门槛较高,需要有Google帐户,而且国内访问受限,所以签发都一直顺畅。

#!/bin/bash
#
#  Godaddy Domain:
DOMAIN=zhenglei.net
DNSAPI=dns_gd
#  Aliyun Domain as Proxy:
DOMAIN_PROXY=778065.xyz
DNSAPI_PROXY=dns_ali
#  Setup CNAME record mapping of _acme-challenge  between ${DOMAIN} and ${DOMAIN_PROXY}
# _acme-challenge.zhenglei.net       CNAME==>   _acme-challenge.778065.xyz
# _acme-challenge.blog.zhenglei.net  CNAME==>   _acme-challenge.778065.xyz
# ...
# nslookup -type=CNAME _acme-challenge.zhenglei.net
# nslookup -type=CNAME _acme-challenge.blog.zhenglei.net
# Aliyun key & secret to generate acme cert
# dnsapi=dns_ali
Ali_Key="Your Aliyun Key"
Ali_Secret="Your Aliyun Secret"
export Ali_Key=${Ali_Key}
export Ali_Secret=${Ali_Secret}
# Godaddy key & secret to generate acme cert
# dnsapi=dns_gd
GD_Key="Your Godaddy Key"
GD_Secret="Your Godaddy Secret"
#
#  Using alias dns mode of acme.sh
M=" --challenge-alias ${DOMAIN_PROXY} "
N=" --challenge-alias no "
#
#
# IP PROTOCOL
IP=--listen-v6
#
#
#
DNSSLEEP=40
# Init
source  /root/env.sh
ACME_SH=/root/.acme.sh/acme.sh
#
#
DSUB=""
DSUB+=" -d ${DOMAIN} ${M}"
DSUB+=" -d ${DOMAIN_PROXY} ${N}"
DSUB+=" -d blog.${DOMAIN} ${M}"
DSUB+=" -d blog.${DOMAIN_PROXY} ${N}"
DSUB+=" -d blog1.${DOMAIN} ${M} "
DSUB+=" -d blog2.${DOMAIN} ${M} "
DSUB+=" -d gallery.${DOMAIN} ${M} "
DSUB+=" -d gallery.${DOMAIN_PROXY} ${N} "
DSUB+=" -d gallery1.${DOMAIN} ${M} "
DSUB+=" -d gallery2.${DOMAIN} ${M} "
DSUB+=" -d music.${DOMAIN} ${M} "
DSUB+=" -d music.${DOMAIN_PROXY} ${N} "
DSUB+=" -d music1.${DOMAIN} ${M} "
DSUB+=" -d music2.${DOMAIN} ${M} "
DSUB+=" -d mpd.${DOMAIN} ${M} "
DSUB+=" -d mpd.${DOMAIN_PROXY} ${N} "
DSUB+=" -d mympd.${DOMAIN} ${M} "
DSUB+=" -d mympd.${DOMAIN_PROXY} ${N} "
DSUB+=" -d stream.${DOMAIN} ${M} "
DSUB+=" -d stream.${DOMAIN_PROXY} ${N} "
DSUB+=" -d video.${DOMAIN} ${M} "
DSUB+=" -d video.${DOMAIN_PROXY} ${N} "
DSUB+=" -d *.${DOMAIN} ${M} "
DSUB+=" -d *.${DOMAIN_PROXY} ${N} "
P=""
P+=" --dns ${DNSAPI_PROXY} "
P+=" --dnssleep ${DNSSLEEP} "
P+=" -k ec-384 "
P+=" --force "#  Issue:
echo "${ACME_SH} --issue  ${P} ${DSUB}"
      ${ACME_SH} --issue  ${P} ${DSUB}
# Install
INST_PATH=/opt/local/cert/acme_zhenglei.net
INST_CER=${INST_PATH}/fullchain.cer
INST_KEY=${INST_PATH}/zhenglei.net.key
# P+=" --debug "
# P+=" --log "
#  Issue:
echo "${ACME_SH} --issue  ${P} ${DSUB}"
      ${ACME_SH} --issue  ${P} ${DSUB}
# Install
INST_PATH=/opt/local/cert/acme_zhenglei.net
INST_CER=${INST_PATH}/fullchain.cer
INST_KEY=${INST_PATH}/zhenglei.net.key
OPENRESTY=/opt/local/etc/init.d/openresty
${ACME_SH} --install-cert -d ${DOMAIN} \
           --key-file ${INST_KEY} \
           --fullchain-file ${INST_CER} \
           --reloadcmd "${OPENRESTY} stop ; ${OPENRESTY} start"

https://github.com/acmesh-official/acme.sh/wiki/DNS-alias-mode

Config Godaddy Smtp Realy

Config 3rd (Godaddy)  SMTP server as the relay of your smtp server

 

Godaddy:

MX records:

0 smtp.secureserver.net
10 mailstore1.secureserver.net

 

Host Names (CNAME)

POP pop.secureserver.net
IMAP imap.secureserver.net
SMTP smtpout.secureserver.net

 

Port:

  • Without SSL
    • Incoming Port
      IMAP – 143
      POP – 110
    • Outgoing (SMTP) port
      One of the following: 25, 80, 3535
  • With SSL
    • Incoming Port
      IMAP – 993
      POP – 995
    • Outgoing (SMTP) port
      465

 

 

Install Postfix

sudo apt-get install mailutils
sudo apt-get install postfix

Config Postfix

sudo nano /etc/postfix/main.cf

Test Postfix SMTP Server Can Send Email

echo "This is the body of the email" | 
mail -s "This is the subject line" xxx@gmail.com

Forward System Mail via the Postfix SMTP Server

cat /etc/aliases

# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root:  account@yourdomain

Send  Mail via external (Godaddy) smtp server

Configuring  Usernames and Passwords

sudo nano    /etc/postfix/sasl/passwd
[smtpout.secureserver.net]:80 account@yourdomain:passwd
sudo postmap /etc/postfix/sasl/passwd

Configuring Relay

sudo nano    /etc/postfix/main.cf

# specify SMTP relay host 
relayhost = [smtpout.secureserver.net]:80

At the end of the file, add the following parameters to enable authentication:

cat /etc/postfix/main.cf

smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd

Test Postfix SMTP Relay

echo "email via godaddy smtp" | 
mail -s "smtp relay" "From: account@yourdomain" xxx@dest

Config email  alias From header in Postfix

 Add the line into /etc/postfix/main.cf

smtp_generic_maps = hash:/etc/postfix/generic

cat /etc/postfix/generic

other-email  account@yourdomain

sudo postmap /etc/postfix/generic

About Godaddy AD

Remove AD:

     Add <script>  in HTML file, just after the tag of </body>

    example:

    <html>
    <body>
        <h1>It works!</h1>
        <p>This is the default web page for this server.</p>
       <p>The web server software is running but no content has been added, yet.</p>
      </body>

      <script>
   </html>

 

 

Hide AD

   Add <style>#conash3D0 {display:none}</style>; in HTML file, just after tag of </body>

  example:

  <html>
    <body>
        <h1>It works!</h1>
     <p>This is the default web page for this server.</p>
     <p>The web server software is running but no content has been added, yet.</p>
    </body>

    <style>#conash3D0 {display:none}</style>;
 </html>