Debian Rclone automount | Rclone 自动挂载

Debian Rclone automount | Rclone 自动挂载

引用

https://github.com/rclone/rclone/wiki/Systemd-rclone-mount#systemd

前提

  • 安装rclone
  • 配置远程服务器,eg:my_remote_service, (default config location: ~/.config/rclone/rclone.conf)

操作

[Unit]
Description=RClone mount of users remote %i using filesystem permissions
Documentation=http://rclone.org/docs/
After=network-online.target

....

Django项目的多语言支持

引用

https://testdriven.io/blog/multiple-languages-in-django/

Django是一个非常流行和强大的Python Web框架,它提供了很多内置的功能,让开发者可以快速地构建高性能、安全、可扩展的网站。其中一个功能就是国际化和本地化,也就是让网站能够根据用户的语言和地区偏好,显示不同的内容和格式。这样,网站就可以覆盖更多的用户群体,提高用户体验和满意度。

在这篇博客中,我将介绍如何使用Django的国际化和本地化功能,以及一些第三方库,来实现多语言网站的开发。我将以一个简单的博客网站为例,展示如何让它支持英语、法语、西班牙语、越南语、波兰语、泰语、韩语、日语、简体中文和繁体中文这十种语言。我将分为以下几个步骤:

  • 基本设置
  • 模型和视图的国际化
  • 模板的国际化
  • URL的国际化
  • 静态文件的国际化
  • 语言切换
  • 使用第三方库

基本设置

首先,我们需要在项目的settings.py文件中,做一些基本的设置,来启用国际化和本地化功能,以及指定支持的语言和默认语言。具体的设置如下:

    # 基本设置

    LANGUAGE_CODE = 'zh-hans' # 默认语言,这里我设置为简体中文
    #PARLER_DEFAULT_LANGUAGE_CODE = 'zh-hans' # 这是一个第三方库的设置,后面会介绍

    TIME_ZONE = 'UTC' # 时区,这里我设置为UTC,你可以根据需要修改

    USE_I18N = True # 启用国际化功能

    USE_L10N = True # 启用本地化功能

    USE_TZ = True # 启用时区支持

    # https://github.com/django/django/blob/main/django/conf/global_settings.py#L56
    LANGUAGES = ( # 指定支持的语言,这里我设置了十种语言,你可以根据需要增加或删除
        ('en', ('English')),
        ('fr', ('Français')),
        ('es', ('Español')),
        ('vi', ('Tiếng việt')),
        ('pl', ('Polskie')),
        ('th', ('ไทย')),
        ('ko', ('한국어')),
        ('ja', ('日本語')),
        ("zh-hans", ("简体中文")),
        ("zh-hant", ("繁體中文"))
    )

    LOCALE_PATHS = [ # 指定存放翻译文件的路径,这里我设置为项目根目录下的locale文件夹
        os.path.join(os.path.dirname(os.path.dirname(__file__)), "locale")
    ]

解决Sitecore 10.1.3 CD环境中的Sitecore多站点之间的internal link问题

在我们的工作中,遇到了一个关于Sitecore站点定义的问题,导致在Sitecore 10.1.3的CD环境中出现了链接生成错误的情况。在此,我将分享这个问题的细节以及解决方案。

引用与参考

https://archive.doc.sitecore.com/xp/en/SdnArchive/SDN5/Articles/Administration/Configuring%20Multiple%20Sites/Adding%20New%20Site/site%20Attribute%20Properties/targetHostName.html
https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB1000633

问题描述

具体现象是在站点A引用站点B的节点时,链接里的/sitecore/content关键字没有被正确解析,导致链接生成错误。需要特别注意的是,这个问题只在CD环境中出现,而在CM环境中是正确的。

发现问题

由于CD环境不能调试,我们创建aspx文件上传到测试CD环境中,来尝试打印一些关键属性

Flarum nginx 配置

官方安装文档

https://docs.flarum.org/install

参考官方安装文档就行,先把基本都安装好,

其中有一个URL Rewriting ,我使用的Nginx,

所以需要创建一个,nginx.site.config

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

    root /path/to/flarum/public;
    index index.html index.htm index.php;
    include /path/to/.nginx.conf;

    # URI 符合正则表达式 [\.php$] 的请求将进入此段配置
    location ~ \.php$ {
        # 配置 FastCGI 服务地址,可以为 IP:端口,也可以为 Unix socket。
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        # 配置 FastCGI 的主页为 index.php。
        fastcgi_index index.php;
        # 配置 FastCGI 参数 SCRIPT_FILENAME 为 $realpath_root$fastcgi_script_name。
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        # 引用更多默认的 FastCGI 参数。
        include fastcgi_params;
    }

    #ssl_certificate xxx
    #ssl_certificate_key yyy

}

Free-HLS 视频床 部署

Github

https://github.com/sxyazi/free-hls

Clone Source Code

cd /var/www
git clone https://github.com/sxyazi/free-hls.git
cd free-hls

修改docker-compose.yml文件,

把APP 映射到宿主机/mnt/free-hls/app

        - app:/var/app
+      - /mnt/hdd/free-hls/uploads:/var/app/web/uploads
....


volumes:
  app:

94采集器下载和安装

下载

这是94采集器下载链接最新版本5.2.4 下载

安装

  1. 下载压缩包之后,解压后上传到服务器,以/var/www/94caiji 目录为例。
  2. 使用的python版本为3.8, 如果当前服务器上安装的不是3.8的版本,建议安装pyenv进行python版本管理。
  3. 使用virtualenv venv 创建虚拟环境。激活venv . venv/bin/activate
  4. 安装依赖 pip install -r requestments.txt, 在安装的过程中可能提示错误如下,修改requestments.txt 为 pyppeteer==0.2.6
ERROR: Cannot install pyppeteer==0.2.5 and pyppeteer==0.2.6 because these package versions have conflicting dependencies.
  1. 可能还需要安装cfscrape, 错误如下, 需要安装 pip install cfscrape
ModuleNotFoundError: No module named 'cfscrape'

测试

执行python3 index.py 看是否可以运行, 如果没有错误,可以正常运行,说明python环境依赖安装完成。

Armbian install Cloudflare tunnel | Armbian 安装 cloudflare tunnel 教程

引用

https://hostloc.com/thread-1154840-1-3.html
https://serverfault.com/questions/10811/how-to-add-a-script-to-startup-and-shutdown-in-debian
https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6

说明

按照些教程准备在armbian安装,前面都很好,就是创建 /etc/init.d/cloudflared启动脚本时,Armbian不工作, 无法启动。
然后就查到了 init已经被systemd替换了,所以就使用systemd来启动cloudflared.
https://serverfault.com/a/946483

Armbian 安装 Transmission

背景

之前一直使用aria2来下载BT,PT,aria2的配置已经修改user-agent来伪装其它下载软件比如transmission.
最近再下载PT时,提示错误,errorCode=1 Tracker returned failure reason: Abnormal access blocked 看样应该是被识别并禁止下载了,
就那换一个吧, Transmission

引用

https://blog.haibara.cn/archives/173
https://github.com/ronggang/transmission-web-control/issues/292
https://ld246.com/article/1556162494650
https://my.oschina.net/CasparLi/blog/830361?utm_source=ld246.com

安装

apt install transmission transmission-daemon

一切正常

配置

首先要停用transmission-daemon服务,执行下面的命令:

service transmission-daemon stop

Django Cache Distinguish Desktop Mobile | Django缓存区分桌面版和手机端

Django Cache Distinguish Desktop Mobile

Django Cache 默认并不区分Desktop和Mobile, 但是如果Desktop 视图和mobile视图不同,这时Django Cache就会有问题,
如果某个页面先被desktop模式访问之后,页面会被缓存,但手机端再访问这个页面时,发布页面已经被缓存,所以直接返回,
但是被缓存的内容是Desktop模式,在手机端显示会有些奇怪。

引用

https://docs.djangoproject.com/zh-hans/4.0/topics/cache/
https://docs.djangoproject.com/zh-hans/4.0/topics/cache/#using-vary-headers
https://github.com/django/django/blob/main/django/utils/cache.py
https://github.com/Botir/Django-Mobile-Detector

Django-Mobile-Detector

Mobile Detector 请参考: https://github.com/Botir/Django-Mobile-Detector

使用Vary Header

Vary Header介绍: https://docs.djangoproject.com/zh-hans/4.0/topics/cache/#using-vary-headers

Nginx return 400 bad request | nginx proxy_pass url decoding

Nginx return 400 bad request

Refer

https://stackoverflow.com/questions/28684300/nginx-pass-proxy-subdirectory-without-url-decoding/37584637#37584637

Background

proxy pass static image to another host, most of requests are ok, but some requests return 400 (bad request).

Enable nginx debug

edit /var/nginx/nginx.conf

        error_log /var/log/nginx/error.log debug;

Track error log

nginx config

location ~ ^/static/images/(.*) {
        proxy_pass http://youranotherdomain/images/$1;
    }

Viagle Blog

欢迎来到我的个人博客网站