在 nginx 里设置 acme 验证证书的目录

需求:acme.sh 建议用非root的用户运行,如果nginx里有多个站点需要验证证书,怎么做较方便呢?

尝试:如 创建一个 acme.conf 的配置文件,内容如下:

#############################################################################
# Configuration file for Let's Encrypt ACME Challenge location
# This file is already included in listen_xxx.conf files.
# Do NOT include it separately!
#############################################################################
#
# This config enables to access /.well-known/acme-challenge/xxxxxxxxxxx
# on all our sites (HTTP), including all subdomains.
# This is required by ACME Challenge (webroot authentication).
# You can check that this location is working by placing ping.txt here:
# /var/www/letsencrypt/.well-known/acme-challenge/ping.txt
# And pointing your browser to:
# http://xxx.domain.tld/.well-known/acme-challenge/ping.txt
#
# Sources:
# https://community.letsencrypt.org/t/howto-easy-cert-generation-and-renewal-with-nginx/3491
#
#############################################################################

# Rule for legitimate ACME Challenge requests (like /.well-known/acme-challenge/xxxxxxxxx)
# We use ^~ here, so that we don't check other regexes (for speed-up). We actually MUST cancel
# other regex checks, because in our other config files have regex rule that denies access to files with dotted names.
location ^~ /.well-known/acme-challenge/ {

    # Set correct content type. According to this:
    # https://community.letsencrypt.org/t/using-the-webroot-domain-verification-method/1445/29
    # Current specification requires "text/plain" or no content header at all.
    # It seems that "text/plain" is a safe option.
    default_type "text/plain";

    # This directory must be the same as in /etc/letsencrypt/cli.ini
    # as "webroot-path" parameter. Also don't forget to set "authenticator" parameter
    # there to "webroot".
    # Do NOT use alias, use root! Target directory is located here:
    # /var/www/common/letsencrypt/.well-known/acme-challenge/
    root         /var/www/acme;
}

# Hide /acme-challenge subdirectory and return 404 on all requests.
# Ending slash is important!
location = /.well-known/acme-challenge/ {
    return 404;
}

然后让web用户在/var/www/acme有写入权限,再在所需站点的配置文件里引用这个acme.conf文件就可以啦。

参考:https://community.letsencrypt.org/t/how-to-nginx-configuration-to-enable-acme-challenge-support-on-all-http-virtual-hosts/5622/3

安装 magento 2.4.6-p1

当前,magento 官方商城使用的程序版本是 magento 2.4.6-p1 。尝试安装一下,记录遇到的问题。

问题一:debian 12系统里,默认安装的mariadb版本是10.11.3,但 magento 要求是10.6。数据库的版本过高,magento安装程序不认。

出错信息:Current version of RDBMS is not supported. Used Version: 10.11.3-MariaDB-1. Supported versions: MySQL-8, MySQL-5.7, MariaDB-(10.2-10.6)

或:

Warning: preg_match(): Compilation failed: range out of order in character class at offset 25 in magento/vendor/magento/framework/DB/Adapter/SqlVersionProvider.php on line 101

尝试:

对于第一个报错,按照网上的例子,修改 magento/app/etc/di.xml 文件内容,如:
<item name="MariaDB-(10.2-10.11)" xsi:type="string">^10\.[2-11]\.</item> 直接修改版本号。

第二个报错,修改 magento/vendor/magento/framework/DB/Adapter/SqlVersionProvider.php 文件内容,如:

        $pattern = sprintf('/(%s)/', implode('|', $this->supportedVersionPatterns));
        $pattern = '/10.11/';
        $sqlVersionOutput = '10.11.3-MariaDB-1';
        preg_match($pattern, $sqlVersionOutput, $match);

问题二:magento 安装程序,连接不上刚刚安装的 opensearch ,提示:Could not validate a connection to the opensearch, no alive nodes found in your cluster

尝试:在 /etc/opensearch/opensearch.yml 文件中,添加一行 plugins.security.disabled: true ,即将opensearch的https和用户访问的安全设置禁用。

问题三:使用 nginx 的反向代理 apache 上的 magento 站点后,https 访问异常,如不断地循环跳转。

magento 的站点网址设置等,和平时的差不多,如下例:

catalog/search/engine - opensearch
catalog/search/opensearch_server_hostname - localhost
catalog/search/opensearch_server_port - 9200
catalog/search/opensearch_index_prefix - magento2
catalog/search/opensearch_server_timeout - 15
catalog/category/root_id - 2
web/seo/use_rewrites - 1
web/unsecure/base_url - http://magento.anqun.org/
web/unsecure/base_static_url -
web/unsecure/base_media_url -
web/secure/base_url - https://magento.anqun.org/
web/secure/base_static_url -
web/secure/base_media_url -
web/secure/enable_hsts - 0
web/secure/enable_upgrade_insecure - 0
web/secure/use_in_frontend - 1
web/secure/use_in_adminhtml - 1
web/secure/offloader_header -
web/default_layouts/default_product_layout - product-full-width
web/default_layouts/default_category_layout - category-full-width
web/default_layouts/default_cms_layout - cms-full-width
web/cookie/cookie_path -
web/cookie/cookie_domain -
web/cookie/cookie_httponly - 1
general/locale/code - zh_Hans_CN
general/locale/timezone - Asia/Shanghai
general/region/display_all - 1
general/region/state_required - AL,AR,AU,BG,BO,BR,BY,CA,CH,CL,CN,CO,CZ,DK,EC,EE,ES,GR,GY,HR,IN,IS,IT,LT,LV,MX,PE,PL,PT,PY,RO,SE,SR,US,UY,VE
currency/options/base - CNY
currency/options/default - CNY
currency/options/allow - CNY
analytics/subscription/enabled - 1
crontab/default/jobs/analytics_subscribe/schedule/cron_expr - 0 * * * *
crontab/default/jobs/analytics_collect_data/schedule/cron_expr - 00 02 * * *

关键应该是设置 https 的环境参数,如通过 .htaccess 添加以下内容:

setenv HTTPS on
SetEnv HTTP_X_FORWARDED_PROTO "https"

如果nginx反代配置中使用了 X-Real-IP 头,那么 apache 中的访问日志,可以使用 LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Real-IP}i\"" proxycombined 来记录访客IP。

nginx站点例子:

server {
        listen       443 ssl;  
        server_name  magento.anqun.org; 

        ssl_certificate          fullchain.cer;
        ssl_certificate_key      magento.anqun.org.key;

        proxy_buffer_size   128k;
        proxy_buffers   4 256k;
        proxy_busy_buffers_size   256k;

        location / {
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_pass         http://192.168.1.9:8001;
        }
}

参考:

切苦瓜

天气炎热,吃一条苦瓜比吃雪糕还解暑。前几天,我在果园菜市场,买到半截青半截黄的苦瓜,以为较甜。我将苦瓜放在砧板上,一刀切落驷,吓我一下。我看到苦瓜里边满是小虫。小虫也受到惊吓,要么往里边钻,蜷成一团;要么左右摇着尾喊疼。我转侧手,看刀口,刀口两侧也粘着几条被斩断的小虫,惨不忍睹。单从外表,苦瓜表皮完整,看不出来是坏的。

今天,我学到了,要避免买到颜色泛黄的苦瓜。事先,我还特意问吖姨,苦瓜有冇虫。吖姨说没有虫,任选。我看到畚箕上有一条切了一截的苦瓜,是好的。于是我买了一斤苦瓜,两块钱。我归来用刀一切,看到苦瓜的芯板结。苦瓜仔有的长不成形,变毛、变成褐色,估计也系烂苦瓜。我看着切开的苦瓜,心里也是苦闷的。扔了它吧,那中午吃什么菜,都快十二点半了。挖开苦瓜坏的芯,吃好的苦瓜皮吧,我这么想。

CSGO 游戏 SDR 服务器 IP 列表

问题:玩 CSGO 游戏,我进入的是 worldwide 平台,一般是连接到位于香港的服务器。之前是直接连接,可以玩。但近段时间,我发现打不着人,挨打的份。我有时觉得倒下了,才看到对方的射击动作。今天无意中看到,状态栏里显示有约12%的丢包率(LOST)。我想,自己能否“加速”一下,将丢包率减到最低,最好不会丢包。

尝试:访问网址 https://api.steampowered.com/ISteamApps/GetSDRConfig/v1?appid=730 ,从获取到的内容中检索出属于 HKG 香港服务器的十个IP地址。然后在电脑里,对这十个IP,或者干脆将 103.28.54.0/24 添加到“加速”列表。测试,现在在游戏中用“内格夫”的机枪,我终于能扫到人了。

参考:

爬东山岭后山 - 2023-07-08

东山岭,离家近,方便;坡不陡,爬后不累;如到后山绕着回来,路程不短,且景色不单调,是约着好友边走边聊的好地方。

同学昨晚约,我起床后买两个包子吃饱后,七点半开始爬。主任看到有人已经湿了衫下山,说,可能现在这季节,五点半天亮后开始爬,适合些,因为七点半已经有太阳照着了。我们爬到路程的中间地点——红旗山时,约八点半。快到时,五、六个小孩象羊羔般兴冲冲地小跑着先后下来,大人在后边喊小孩的名字,生怕落下了一个。导师用他的GoPro相机,测了下海拔,469米。之后,我们朝火车站方向下山,用了约二十分钟。最后是沿着和优公路,走到进火车站的大路上。我到家附近时看表,走这水泥路段花了约一个小时。我顺带着在路边店里买点菜,准备煮昼吃。

全程用了约两个半小时。不算晒,因为大半的路上有树荫,且山里有时会吹来凉风。走着泥土路、看着不间隔绿色的景色、时不时感受微微的凉风。我们边走边随意聊天,呵呵笑,挺舒服的。

  1. 石油新村路段 - 石墙 - IMG_20230708_073121752
  2. 石油新村路段 - 扭扭形路 - IMG_20230708_073216361
  3. 左侧绕到东山岭后山路段 - IMG_20230708_073515782
  4. 左侧绕到东山岭后山路段 - 拗腰的树 - IMG_20230708_073952769
  5. 东山岭后山坳 - IMG_20230708_074347027
  6. 东山岭后山 - 上昼的日头照在路上 - IMG_20230708_074851332
  7. 东山岭后山 - IMG_20230708_075126741
  8. 去红旗山路上 - 泥阶路 - IMG_20230708_080326822
  9. 去红旗山路上 - IMG_20230708_082648125
  10. 去红旗山路上 - IMG_20230708_082831993
  11. 去红旗山路上 - IMG_20230708_083026488
  12. 去红旗山路上 - IMG_20230708_083110753
  13. 去红旗山路上 - IMG_20230708_083135457
  14. 去红旗山路上 - IMG_20230708_083548118
  15. 去红旗山路上 - IMG_20230708_083655102
  16. 去红旗山路上 - IMG_20230708_083740918
  17. 去红旗山路上 - IMG_20230708_083803227
  18. 朝火车站方向下山 - 前些天下雨,路没人行。长绿苔,会滑 IMG_20230708_085127717
  19. 朝火车站方向下山 - IMG_20230708_085239697_HDR
  20. 朝火车站方向下山 - 路边的绿箕 - IMG_20230708_085344432
  21. 朝火车站方向下山 - 路边的“农林山界” - IMG_20230708_085540364
  22. 朝火车站方向下山 - 三角条凳 - IMG_20230708_085608256
  23. 朝火车站方向下山 - IMG_20230708_085703887
  24. 朝火车站方向下山 - IMG_20230708_090029133
  25. 朝火车站方向下山 - IMG_20230708_090238862
  26. 朝火车站方向下山 - IMG_20230708_090401264
  27. 朝火车站方向下山 - IMG_20230708_090437828
  28. 朝火车站方向下山 - IMG_20230708_090752799
  29. 朝火车站方向下山 - IMG_20230708_090822948
  30. 朝火车站方向下山 - IMG_20230708_090909406
  31. 朝火车站方向下山 - IMG_20230708_090940579
  32. 朝火车站方向下山 - IMG_20230708_091111614
  33. 朝火车站方向下山 - IMG_20230708_091201842
  34. 在和优公路上 - IMG_20230708_091448818_HDR
  35. 在和优公路上 - IMG_20230708_091709944
  36. 在和优公路上 - 路边有一条山涯水管,洗手好凉 - IMG_20230708_092606280_HDR
  37. 在和优公路上 - 主任说十点太阳影在路一侧,走着冇嘅热 - IMG_20230708_093418265_HDR
  38. 在火车站路上 - IMG_20230708_095416765

微信公众号里贴了图片,这里就不重复了:https://mp.weixin.qq.com/s?__biz=Mzg2NjY4MTk0NA==&mid=2247484274&idx=1&sn=1e22710fd6979f846cfee5ddd4b14d2c