BuyPass 免费域名 SSL 证书ACME API申请方法

BuyPass 是挪威的一家 CA 机构,提供数字证书、安全认证产品等多种服务。目前 BuyPass 提供了类似 Let’s Encrypt 的基于 ACME/Certbot 的证书自动签发服务 – BuyPass GO Free SSL,免费!

与 Let’s Encrypt 主要的不同点在于 BuyPass 证书每次签发有效期是 180 天( Let’s Encrypt 是 90 天)。另外 BuyPass 不支持签发泛域名证书,但支持多域名。

由于目前 Let’s Encrypt OCSP 存在问题(ocsp.int-x3.letsencrypt.org 被干扰),严重拖慢网站速度,因此可以考虑替换为 BuyPass。
继续阅读BuyPass 免费域名 SSL 证书ACME API申请方法

openwrt无法识别USB千兆网卡

最近几天不知道怎么回事,自己的openwrt好端端的就出现问题了,网络不通了,可以发现是dhcp不工作,没有下发ip,可问题是最近我没有动过路由器啊,很奇怪。

于是乎,重置路由器,不行。

只能换一个其他版本的openwrt了,于是换了一个版本,发现usb网卡拔插以后,只有如下信息:
继续阅读openwrt无法识别USB千兆网卡

Maddy:多合一邮件服务器

我自己有几台VPS,平时都是吃灰状态,或者,除了翻墙,也再没做什么用途,感觉有点浪费,偶然,我发现了这个Maddy这个好东西,免去了自己配置postfix,dovecat等等之类的服务,仅仅需要配置一个文件就可以了。是不是很容易?

而且,还可以让自己的VPS发挥一点作用,对于长期持有的域名,真的不失为一个很好的用途,你们说呢?

Maddy Mail Server implements all functionality required to run a e-mail server. It can send messages via SMTP (works as MTA), accept messages via SMTP (works as MX) and store messages while providing access to them via IMAP. In addition to that it implements auxiliary protocols that are mandatory to keep email reasonably secure (DKIM, SPF, DMARC, DANE, MTA-STS).
It replaces Postfix, Dovecot, OpenDKIM, OpenSPF, OpenDMARC and more with one daemon with uniform configuration and minimal maintenance cost.

Maddy是一款用Go语言开发的邮件服务器,它实现了运行电子邮件服务器所需的所有功能。

Maddy用一个具有统一配置和最低维护成本的守护进程取代了Postfix、Dovecot、OpenDKIM、OpenSPF、OpenDMARC 等程序。
继续阅读Maddy:多合一邮件服务器

使用 DOCKER 自建支持 DOH、DOT 的 DNS 服务器

DoH (DNS over HTTPS) 和 DoT (DNS over TLS) 有效避免了运营商的 DNS 监听和劫持,本文记录在公网搭建一个可以去广告的 DNS 服务器(借助 Adguard Home)。

前期准备

VPS配置不可描述服务

准备工作

  • 一台域外VPS
  • 一个域名
  • 将域名解析到VPS的IP上。

1. 开启bbr优化

wget -N --no-check-certificate "https://github.000060000.xyz/tcp.sh" && chmod +x tcp.sh && ./tcp.sh

""

先输入11,启用bbr+fq加速,然后输入22,应用优化方案,之后需要重启VPS。

2. 安装xray

bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install

3. 安装acme脚本

curl https://get.acme.sh | bash

4. 创建Geo脚本

vi /usr/local/bin/xray-geo

#!/bin/bash
rm -fr /usr/local/share/xray/geo*.dat
wget -O /usr/local/share/xray/geoip.dat https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat
wget -O /usr/local/share/xray/geosite.dat https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat
echo 'Geo Files have been updated'

systemctl restart xray
echo 'Xray service restarted'

给予可执行权限

chmod +x /usr/local/bin/xray-geo

5. 申请SSL证书及安装证书

申请证书

/root/.acme.sh/acme.sh --issue -d www.example.com --standalone

安装证书

/root/.acme.sh/acme.sh --install-cert -d www.example.com --fullchain-file /usr/local/etc/xray/example.cer --key-file /usr/local/etc/xray/example.key

chown nobody.root /usr/local/etc/xray/example.*

为了便于未来自动更新证书,可以创建如下脚本,放入crontab自动执行。

vi /usr/local/bin/xray-renew

文件内容:

#!/bin/bash
/root/.acme.sh/acme.sh --install-cert -d www.exmaple.com --fullchain-file /usr/local/etc/xray/example.cer --key-file /usr/local/etc/xray/example.key
echo "Xray Certificates Renewed"

chown nobody.root /usr/local/etc/xray/example.*

echo "User&Group Changed for Xray"

systemctl restart xray
echo "Xray Restarted"

授予可执行权限

chmod +x /usr/local/bin/xray-renew

增加计划任务

crontab -e

在文件中增加如下内容,意思是每个星期五的凌晨2点执行一次 xray-renew 脚本。

0 2 * * 5 bash /usr/local/bin/xray-renew

可看下图

""

6. 生成UUID,修改配置文件

在命令提示符下输入下面的命令,就会返回一个新生成的UUID,将这个UUID保存一下。

root@nerd:~# xray uuid
f47cdd50-7468-4758-afb8-1fd3a4887a49

在下面的xray配置文件中,修改所有的uuid为上面生成的UUID。

{
    // 1_日志设置
    "log": {
        "loglevel": "warning",
        "access": "/var/log/xray/access.log",
        "error": "/var/log/xray/error.log"
    },
    // 2_路由设置(白名单)
    "routing": {
        "rules": [
            {
              "type": "field",
              "outboundTag": "Reject",
              "domain": [
                "geosite:category-ads-all"
              ]
            },
            {
              "type": "field",
              "outboundTag": "Direct",
              "domain": [
                "geosite:private",
                "geosite:apple-cn",
                "geosite:google-cn",
                "geosite:tld-cn",
                "geosite:category-games@cn"
              ]
            },
            {
              "type": "field",
              "outboundTag": "Proxy",
              "domain": [
                "geosite:geolocation-!cn"
              ]
            },
            {
              "type": "field",
              "outboundTag": "Direct",
              "domain": [
                "geosite:cn"
              ]
            },
            {
             "type": "field",
             "outboundTag": "Proxy",
             "network": "tcp,udp"
            }
        ]
    },
    // 3_DNS设置
    "dns": {
        "hosts": {
          "dns.google": "8.8.4.4",
          "doh.pub": "119.29.29.29"
        },
        "servers": [
          "https://dns.google/dns-query",
        {
          "address": "https+local://223.5.5.5/dns-query",
          "domains": [
            "geosite:cn",
            "geosite:icloud",
            "geosite:category-games@cn"
          ],
          "expectIPs": [
            "geoip:cn"
          ]
        },
        {
          "address": "https://1.1.1.1/dns-query",
          "domains": [
            "geosite:geolocation-!cn"
          ]
        }
      ]
    },
    // 4_入站设置
    "inbounds": [
        {
            "port": 8443,
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "uuid", // 填写你的 UUID
                        "flow": "xtls-rprx-direct",
                        "level": 0,
                        "email": "love@example.com"
                    }
                ],
                "decryption": "none",
                "fallbacks": [
                    {
                        "dest": 1310, // 默认回落到 Xray 的 Trojan 协议
                        "xver": 1
                    },
                    {
                        "path": "/ws1169", // 必须换成自定义的 PATH
                        "dest": 1234,
                        "xver": 1
                    },
                    {
                        "path": "/vst1170", // 必须换成自定义的 PATH
                        "dest": 2345,
                        "xver": 1
                    },
                    {
                        "path": "/vmw1171", // 必须换成自定义的 PATH
                        "dest": 3456,
                        "xver": 1
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "xtls",
                "xtlsSettings": {
                    "alpn": [
                        "http/1.1"
                    ],
                    "certificates": [
                        {
                            "certificateFile": "/usr/local/etc/xray/example.cer", //SSL证书
                            "keyFile": "/usr/local/etc/xray/example.key" //ssl密钥
                        }
                    ]
                }
            }
        },
        {
            "port": 1310,
            "listen": "127.0.0.1",
            "protocol": "trojan",
            "settings": {
                "clients": [
                    {
                        "password": "mima", // 填写你的密码
                        "level": 0,
                        "email": "love@example.com"
                    }
                ],
                "fallbacks": [
                    {
                        "dest": 80 // 或者回落到其它也防探测的代理
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "none",
                "tcpSettings": {
                    "acceptProxyProtocol": true
                }
            }
        },
        {
            "port": 1234,
            "listen": "127.0.0.1",
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "uuid", // 填写你的 UUID
                        "level": 0,
                        "email": "love@example.com"
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "security": "none",
                "wsSettings": {
                    "acceptProxyProtocol": true, // 提醒:若你用 Nginx/Caddy 等反代 WS,需要删掉这行
                    "path": "/ws1169" // 必须换成自定义的 PATH,需要和分流的一致
                }
            }
        },
        {
            "port": 2345,
            "listen": "127.0.0.1",
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "id": "uuid", // 填写你的 UUID
                        "level": 0,
                        "email": "love@example.com"
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "none",
                "tcpSettings": {
                    "acceptProxyProtocol": true,
                    "header": {
                        "type": "http",
                        "request": {
                            "path": [
                                "/vst1170" // 必须换成自定义的 PATH,需要和分流的一致
                            ]
                        }
                    }
                }
            }
        },
        {
            "port": 3456,
            "listen": "127.0.0.1",
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "id": "uuid", // 填写你的 UUID
                        "level": 0,
                        "email": "love@example.com"
                    }
                ]
            },
            "streamSettings": {
                "network": "ws",
                "security": "none",
                "wsSettings": {
                    "acceptProxyProtocol": true, // 提醒:若你用 Nginx/Caddy 等反代 WS,需要删掉这行
                    "path": "/vmw1171" // 必须换成自定义的 PATH,需要和分流的一致
                }
            }
        }
    ],
    // 5_出站设置
    "outbounds": [
        // 5.1 第一个出站是默认规则,freedom就是对外直连(vps已经是外网,所以直连)
        {
            "tag": "direct",
            "protocol": "freedom"
        },
        // 5.2 屏蔽规则,blackhole协议就是把流量导入到黑洞里(屏蔽)
        {
            "tag": "block",
            "protocol": "blackhole"
        }
    ]
}

建议copy出来,粘贴到notepad等文本编辑器中修改,修改好后,复制全文,粘贴到xray的/usr/local/etc/xray/config.json文件中,或者,另存为config.json并上传到/usr/local/etc/xray目录中。

7. 更新资源文件并重启

xray-geo

8. 检查服务是否在监听中

ss -lptun

查看监听端口

""

great! 服务已经启动了。现在可以在你本地的openwrt或者客户端中配置并使用了,客户端的配置我就不赘述了。

《全文完》

部署WordPress+PostgreSQL

想起来PostgreSQL这么优秀的开源数据库,难道Wordpress不支持吗?于是乎一番搜索,发现Wordpress原生是不支持PostgreSQL的,只能通过插件的形式更换数据库,这个插件名叫PG4WP

准备工作

首先,备份数据库,并且,导出XML文件,XML文件是用来在新安装的wordpress中导入的,因为mysql导出的SQL,无法直接用到PostgreSQL的。

导出完成后,reinstall操作系统吧,装好后,可以使用oneinstack之类的脚本,或者,自己安装PostgreSQL,php,nginx这些,还比脚本之类的快一点,效率为上,直接手工apt安装即可。

域名提前做好解析。

1. 安装必需的库

apt install curl wget gnupg2 ca-certificates lsb-release socat git

2. 安装PostgreSQL

# 引入postgreSQL官方源
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# 导入密钥签名:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

# 更新软件包库:
apt-get update

# 安装PostgreSQL.
# 如果要安装特定版本,那就用'postgresql-12' 或者 'postgresql':
apt-get -y install postgresql

3. 修改PostgreSQL本地认证

vi /etc/postgresql/12/main/pg_hba.conf

//对于local的认证修改为md5

local   all             all                                     md5

4. 启动数据库

systemctl enable postgresql
systemctl start postgresql

5.安装php

apt install php7.3 php7.3-curl php7.3-fpm php7.3-gd php7.3-json php7.3-mbstring 
php7.3-mysql php7.3-opcache php7.3-pgsql php7.3-xml php7.3-xmlrpc php7.3-zip

6. 安装nginx

# 添加nginx官方源
echo "deb http://nginx.org/packages/debian `lsb_release -cs` nginx" 
    | tee /etc/apt/sources.list.d/nginx.list

# 导入源签名密钥
curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add -

# 更新软件仓库
apt update

# 安装nginx
apt install nginx

7. 安装acme.sh

curl  https://get.acme.sh | sh

8. 生成dhparam文件

mkdir /etc/nginx/ssl
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048

9. 创建普通用户

useradd -m -d /web www
mkdir /web/{wwwroot,wwwlogs}
chown -R www.www /web

10. 修改配置文件

nginx配置文件

user  www www
worker_processes autoworker_cpu_affinity auto
error_log  /var/log/nginx/nginx_error.log  crit
pid        /var/run/nginx.pid
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200
events
    {
        use epoll        worker_connections 51200        multi_accept off        accept_mutex off    }

http
    {
        include       mime.types        default_type  application/octet-stream
        server_names_hash_bucket_size 128        client_header_buffer_size 32k        large_client_header_buffers 4 32k        client_max_body_size 50m
        sendfile on        sendfile_max_chunk 512k        tcp_nopush on
        keepalive_timeout 60
        tcp_nodelay on
        fastcgi_connect_timeout 300        fastcgi_send_timeout 300        fastcgi_read_timeout 300        fastcgi_buffer_size 64k        fastcgi_buffers 4 64k        fastcgi_busy_buffers_size 128k        fastcgi_temp_file_write_size 256k
        gzip on        gzip_min_length  1k        gzip_buffers     4 16k        gzip_http_version 1.1        gzip_comp_level 2        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss        gzip_vary on        gzip_proxied   expired no-cache no-store private auth        gzip_disable   "MSIE [1-6]."
        #limit_conn_zone $binary_remote_addr zone=perip:10m;
        ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

        server_tokens off        access_log off
	include /etc/nginx/conf.d/*.conf}

php.conf

vi /etc/nginx/php.conf
location ~ [^/].php(/|$)
        {
            fastcgi_pass  unix:/run/php/php7.3-fpm.sock
            fastcgi_index index.php
            include fastcgi_params
            fastcgi_split_path_info ^(.+?.php)(/.*)$
            set $path_info $fastcgi_path_info
            fastcgi_param PATH_INFO       $path_info
            try_files $fastcgi_script_name =404
        }

/etc/nginx/fastcgi_params文件

新增一行在最后一行

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name

php-fpm

编辑/etc/php/7.3/fpm/pool.d/www.conf文件,使用如下配置即可

[www]
listen = /run/php/php7.3-fpm.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
pm.max_requests = 1024
pm.process_idle_timeout = 10s
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = /var/log/slow.log

8. 启动nginx,php-fpm

systemctl enable php7.3-fpm
systemctl enable nginx
systemctl restart php7.3-fpm
systemctl restart nginx

9. 签发ssl证书

source .bashrc
acme.sh --issue -d www.mydomain.com --standalone

如无意外,应该会看到签发的证书的具体位置,例如/root/.acme.sh/www.mydomain.com/fullchain.cer/root/.acme.sh/www.mydomain.com/www.mydomain.com.key。但是我们还需要将证书安装到nginx的ssl目录,而不是直接使用上面目录的证书,会有权限问题,再者目录会发生变化。

acme.sh --install-cert -d www.example.com 
--key-file       /etc/nginx/ssl/www.mydomain.com.key 
--fullchain-file /etc/nginx/ssl/fullchain.cer 
--reloadcmd     "service nginx force-reload"

10. 给nginx增加虚拟主机

新建配置文件 vi /etc/nginx/conf.d/mydomain.conf

server
        {
        listen          80
        server_name www.mydomain.com mydomain.com
        return 301 https://www.mydomain.com$request_uri
}

server
        {
        listen 443 ssl http2
        #listen [::]:443 ssl http2;
        server_name     www.mydomain.com mydomain.com
        index index.html index.htm index.php default.html default.htm default.php
        root  /web/wwwroot/www.mydomain.com

    location / {
        try_files $uri $uri/ /index.php?$args
        index  index.php
    }

        ssl_certificate /etc/nginx/ssl/fullchain.cer
        ssl_certificate_key /etc/nginx/ssl/www.mydomain.com.key
        ssl_session_timeout 5m
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3
        ssl_prefer_server_ciphers on
        ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"
        ssl_session_cache builtin:1000 shared:SSL:10m
        ssl_dhparam /etc/nginx/ssl/dhparam.pem

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        location ~ /(wp-content|uploads|wp-includes|images)/.*.php$ { deny all }

        include php.conf

        location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d
        }

        location ~ .*.(js|css)?$
        {
            expires      12h
        }

        location ~ /.well-known {
            allow all
        }

        location ~ /.
        {
            deny all
        }

        access_log  /web/wwwlogs/mydomain.log
}

11. 测试虚拟主机是否工作正常

新建一个phpinfo测试脚本vi /web/wwwroot/www.mydomain.com/t.php

<?php3
    phpinfo
?>

用浏览器打开 http://www.mydomain.com/t.php 验证

  • 是否如我们期待跳转到https
  • 是否能解析php脚本

如无意外,你应该能看到地址栏的小锁子了,并且PHP成功解析。

"file"

12. 为Wordpress创建数据库

su - postgres
psql
postgres=# create database your_database;
postgres=# create user your_user with password ‘your_password’;
postgres=# grant all privileges on database your_database to your_user;
postgres=# q

OK. 至此数据已经成功创建了。现在你就可以试试登录数据库。

psql -U your_user -W
Password:
psql (12.4 (Debian 12.4-1.pgdg100+1))
Type "help" for help.

your_database=>
your_database=> q

13. 下载最新的wordpress版本

cd /web/wwwroot/www.mydomain.com
wget https://wordpress.org/latest.tar.gz -O - | tar -zvx
mv wordpress/* ./
rm -fr wordpress

14. 安装pg4wg插件

cd /web/wwwroot/www.mydomain.com/wp-content
git clone https://github.com/gmercey/PG4WP.git
cp PG4WP/db.php ./db.php

15. 调整目录和文件的权限

因为nginx和php-fpm都是以www用户权限跑的,所以需要将web目录下的文件和目录,调整权限,否则无法安装,更新插件,主题等。

chown -R www.www /web

16.配置wordpress数据库信息

默认会有一份wp-config-sample.php的文件,cp一份作为我们配置的起点。

vi wp-config-sample.php wp-config.php

修改如下内容:

/** The name of the database for WordPress */
define('DB_NAME', 'your PostgreSQL database name will go here'
/** MySQL database username */
define('DB_USER', 'your PostgreSQL database username will go here'
/** MySQL database password */
define('DB_PASSWORD', 'your PostgreSQL database password will go here'
/** MySQL hostname */
define('DB_HOST', 'localhost'

17. 安装wordpress

用浏览器打开https://www.mydomain.com/wp-admin/install.php启动wordpress安装程序。

需要注意一下,一定要安装php-mysql 这个扩展,如果不装,wordpress安装开始就报错了。

18. 导入xml

安装完成后,就开始导入吧!

全文结束

使用Proxifier加速git

基于众所周知的原因,gitlab,github要上传下载代码实在是太慢了,很多人使用git config配置全局代理的方式加速上传下载。

今天我想分享一种不一样的加速方式,就是通过proxifier软件。

因为我这边需要使用proxifier将连接到办公室的网络代理到本地,所以平时在家里都是经常打开这个软件的。

proxifier可以从我的网盘下载,或者,从百度上搜索下载,很方便的。安装完成后,运行程序,如下图:

""

然后添加代理服务器,保存一下。

""

接下来就是配置规则了,我研究了一下,原本以为是通过git.exe上传下载的,结果发现是ssh.exe,既然知道了,配置一条根据应用程序代理的规则,很简单了。

""

配置以后,试试吧,是不是速度飞起来了? 🙂

使用Github+jsDelivr+PicGo搭建图床

  • GitHub:全球最大开源托管站,微软旗下。
  • jsDelivr:免费、稳定的CDN
  • PicGo:开源的图片上传程序,支持win、linux等系统。

一、Github设置

1.新建仓库

新建一个public仓库。

2.获取token

打开 https://github.com/settings/tokens,点击右侧的 Generate new token

二、PicGo设置

看下图

""

三、引用地址

前缀为 https://cdn.jsdelivr.net/gh/xxx/yyy ,后面xxx/yyy是github用户名和仓库