甲骨文服务器

申请ssl证书

acme.sh 说明

# install docker on ubuntu or debian
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh --dry-run

# 安装acme.sh
sudo apt install socat
curl https://get.acme.sh | sh -s email=my@example.com # 修改 email 为其他的

# 先给网站设置一个www 目录, /home/vpsadmin/www/webpage

# 测试申请
acme.sh --issue --server letsencrypt --test -d example.com -d www.example.com -w /home/vpsadmin/www/webpage --keylength ec-256

# 申请证书
acme.sh --issue -d example.com -d www.example.com --nginx

# 其中,-d参数指定申请证书的域名,--nginx参数表示使用nginx自动配置证书。

# 安装证书
acme.sh --install-cert -d ct.scnumath.eu.org --key-file /home/ubuntu/ssl/xxx/cert.key --fullchain-file /home/ubuntu/ssl/xxx/fullchain.crt

# 或者使用 CF 域名方式
acme.sh --issue --test --dns dns_cf -d 'xxx.example.com'  --server letsencrypt

acme.sh --issue --dns dns_cf -d 'xxx.example.com'  --server letsencrypt --force 

acme.sh --install-cert -d 'xxx.example.com' \
    --key-file /home/debian/ssl/xxxx/cert.key \
    --fullchain-file /home/debian/ssl/xxxx/fullchain.crt \
    --reloadcmd "docker exec nginx nginx -s reload"

注意:在申请证书之前,需要先将域名解析到服务器的IP地址上,并确保80端口和443端口可以访问。

Nginx 设置ssl

server {
    listen 80;
    server_name xxx.example.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name xxx.example.com;

    ssl_certificate      /etc/nginx/ssl/cert.pem;
    ssl_certificate_key  /etc/nginx/ssl/key.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;

    if ($ssl_server_name != $server_name) {
        return 404;
    }

    location / {
        proxy_pass http://127.0.0.1:3002;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_buffering off;
    }
}


server {
    listen 80 default_server;
    listen 443;
    server_name _;

    if ($server_port ~ 443){
        return 301 http://$server_name$request_uri;
    }

    return 404;
}

重装系统

参考

1. 首先将失联的ARM进行关机
2. 分离引导卷
3. 将引导卷附加到另一台机器上
4. 安装提示的命令 附加卷
5. 下载DD救援包

ubuntu18.04 ARM 官方原版完整救援包(用户名:root , 密码:CNBoy.org) 
wget --no-check-certificate https://github.com/honorcnboy/BlogDatas/releases/download/OracleRescueKit/ubuntu18.04.arm.img.gz 
* 恢复数据约46G,耗时约1个多小时 

ubuntu18.04 AMD 官方原版完整救援包(用户名:root , 密码:CNBoy.org) 
wget --no-check-certificate https://github.com/honorcnboy/BlogDatas/releases/download/OracleRescueKit/ubuntu18.04.amd.img.gz 
* 恢复数据约46G,耗时约1个多小时 

debian10 ARM 网络精简救援包(用户名:root , 密码:10086.fit) 
wget --no-check-certificate https://github.com/honorcnboy/BlogDatas/releases/download/OracleRescueKit/dabian10.arm.img.gz 
* 恢复数据约3G,耗时约10多分钟

6. 恢复镜像到 /dev/sdb 分区
说明:为了防止你在SSH连接在恢复数据中途中断导致失败,建议使用 srceen 后台窗口运行以下命令

gzip -dc '救援包完整路径' | dd of='引导卷加载路径' 

例: 
使用 ubuntu18.04 ARM 官方原版完整救援包,命令如下: 
gzip -dc /root/ubuntu18.04.arm.img.gz | dd of=/dev/sdb 

使用 ubuntu18.04 AMD 官方原版完整救援包,命令如下: 
gzip -dc /root/ubuntu18.04.amd.img.gz | dd of=/dev/sdb 

使用 debian10 ARM 网络精简救援包,命令如下: 
gzip -dc /root/dabian10.arm.img.gz | dd of=/dev/sdb
# 7. 重装系统
bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') \
-d 10 -v 64 -p "自定义root密码" \
-port "自定义ssh端口" -a -firmware

sudo bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -u 22.04 -v arm64 --mirror http://archive.ubuntu.com/ubuntu -p "asd357.." -port "6931"


# -firmware      额外的驱动支持 
# -d             Debian系统 后面是系统版本号,例:9、10 ... 
# -c             Centos系统 后面是系统版本号,例:6.9、6.10 ... 
# -u             Ubuntu系统 后面是系统版本号,例:16.04、18.04 ... 
# -v             系统位数,64位或32位,只写数字 
# -a             auto,全自动无人值守安装 
# -mirror       后面是指定镜像源地址 
# -p             后面写自定义密码 
# –ip-addr      ifconfig -a 后获取到的 例:194.87.xxx.xxx 
# –ip-gate      route -n 后获取到的 例 194.87.xxx.xxx 
# –ip-mask      255.255.xxx.xx

使用 ufw,关闭 iptables

# 获取 ipv6
# For AMD machines
sudo dhclient -6 ens3
# For ARM machines
sudo dhclient -6 enp0s3

# 处理 iptables
sudo iptables -F
sudo iptables -X
sudo iptables -Z
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t nat -Z

# ipv6
sudo ip6tables -F
sudo ip6tables -X
sudo ip6tables -Z
sudo ip6tables -t nat -F
sudo ip6tables -t nat -X
sudo ip6tables -t nat -Z

sudo ufw allow ssh
sudo ufw allow 9281/tcp # other ssh port
sudo ufw enable

增加 swap 分区

sudo mkdir /swap

# sudo dd if=/dev/zero of=/swap/swapfile bs=1M count=2048
sudo fallocate -l 2G /swap/swapfile
sudo chmod 600 /swap/swapfile

sudo mkswap /swap/swapfile
sudo swapon /swap/swapfile
# 编辑 /etc/fstab 文件
/swap/swapfile swap swap defaults 0 0

sudo mount -a

设置时区

timedatectl set-timezone Asia/Shanghai

volumes:
   - /etc/timezone:/etc/timezone:ro
   - /etc/localtime:/etc/localtime:ro

he.net

# ubuntu 使用 netplan 修改网络配置
sudo apt install openvswitch-switch

sudo touch /etc/netplan/99-he-tunnel.yaml
sudo chmod 600 /etc/netplan/99-he-tunnel.yaml
network:
  version: 2
  tunnels:
    he-ipv6:
      mode: sit
      remote: xxxxx
      local: eth0 网卡的ip, 如10.0.0.4
      addresses:
        - "xxxxxxxxxxx/64"
      routes:
        - to: default
          via: "xxxxxxxxxx"
          metric: 99 # 可选

最后修改于 2023-12-17