跳转到帖子

剑弗

网站管理
  • 注册日期

博客帖子 发布由 剑弗

  1. IPS5/IC5修改记录

    自定义钩子(增加游客模糊效果)
    {{if !member.member_id}} <style> .content-blur { filter: blur(3px); pointer-events: none; user-select: none; } .blur-overlay { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 9999; background: rgba(255,255,255,0.8); padding: 20px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; font-size: 20px; color: #333; } .blur-overlay a { color: #0066cc; text-decoration: underline; } </style> <script> document.addEventListener("DOMContentLoaded", function () { const urlPath = window.location.pathname; const isTargetPage = urlPath.match(/^\/(topic|blogs|files)\//); if (isTargetPage) { // 找到内容区域 - 根据你的网站结构调整选择器 const contentArea = document.querySelector('.content-area, .post-content, .article-content') || document.querySelector('main, article') || document.getElementById('content'); if (contentArea) { // 只模糊内容区域 contentArea.classList.add("content-blur"); // 添加遮罩层 const overlay = document.createElement("div"); overlay.className = "blur-overlay"; overlay.innerHTML = '您需要 <a href="/login">登录</a> 才能查看完整内容'; // 将遮罩层插入到内容区域附近 contentArea.parentNode.insertBefore(overlay, contentArea.nextSibling); } } }); </script> {{endif}}
  2. CXCBLOG 伪静态文件备份

    # 使用全局定义的 $lowercase_uri 变量 # if ($request_uri ~ [A-Z]) { # return 301 $scheme://$host$lowercase_uri; # } # 合并版 # if ($request_uri ~* ^/(devops|note|code|video|guoxue)[0-9]*/(?:.*/)?([0-9a-zA-Z_-]+\.html)$) { # return 301 /$2; # } # 不合并版 # devops if ($request_uri ~* ^/devops[0-9]*/.*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } if ($request_uri ~* ^/devops[0-9]*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } # code if ($request_uri ~* ^/code[0-9]*/.*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } if ($request_uri ~* ^/code[0-9]*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } # note if ($request_uri ~* ^/note[0-9]*/.*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } if ($request_uri ~* ^/note[0-9]*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } # guoxue if ($request_uri ~* ^/guoxue[0-9]*/.*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } if ($request_uri ~* ^/guoxue[0-9]*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } # video if ($request_uri ~* ^/video[0-9]*/.*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; } if ($request_uri ~* ^/video[0-9]*/([0-9a-zA-Z_-]+\.html)$) { return 301 /$1; }
  3. IPS5自定义CSS

    /* 自定义内容字体 */ .ipsRichText{ font-family: "Georgia", "Times New Roman", serif; }/*自定义背景图像*/ .ipsLayout__main { background-image: url({resource="custom/yourimage.png" app="core" location="front"}); /*background-image: url(https://yoursite/images/pic.png);*/ width: 100%; background-position: center bottom; background-size: cover; background-repeat: no-repeat; }/* 作者在线状态 */ .ipsEntry__author-online { display: block; }/* 作者在线状态 */ .ipsEntry__author-online { border: 1.1em solid hsl(113deg 76.22% 37.79%); animation: ipsOnlineStatus 1s infinite; border-bottom-color: transparent; border-inline-end-color: transparent; display: block; }/* 反向用户导航 */ .ipsUserNav--member{ flex-direction: row-reverse; }
    /*要仅隐藏描述,请添加以下内容*/ @container (max-width:750px){ .ipsData--table.ipsData--forum-category .ipsData__desc{ display: none; } }
    /*要隐藏描述和最新文章,请添加以下内容*/ @container (max-width:750px){ .ipsData--table.ipsData--forum-category :is(.ipsData__desc, .ipsData__last){ display: none; } }
  4. Discourse运行多容器

    分别在目录中新建不同的文件夹,例如discourse1 discourse2 discourse3(不同的命名为不同的容器项目)
    重命名app.yml,例如app1.yml app2.yml app3.yml(不同的命名为不同的容器项目)
    修改app.yml 中的配置文件(假如是第二个容器,其配置文件如下,仅修改示例中的,其他不变)
    volumes: - volume: host: /www/discourse2/shared/standalone2 guest: /shared - volume: host: /www/discourse2/shared/standalone2/log/var-log guest: /var/log
  5. AWS EC2 Ubuntu 默认使用ROOT密码登陆

    sudo -i (切换root用户)
    sudo passwd root(修改root密码)
    vim /etc/ssh/sshd_config(编辑配置文件)
    PermitRootLogin yes(修改为YES)
    PasswordAuthentication yes(修改为YES)
    cd /etc/ssh/sshd_config.d(进入目录)
    vim 60-cloudimg-settings.conf(编辑配置文件)
    PasswordAuthentication yes(修改为YES)
    sudo service ssh restart 或 sudo systemctl restart ssh (重启SSH)



  6. location / { proxy_pass http://0.0.0.0:10443; # 设置反向代理到目标地址 proxy_set_header Host $host; # 转发 Host 头 proxy_set_header X-Real-IP $remote_addr; # 转发客户端真实 IP proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 转发客户端 IP proxy_set_header X-Forwarded-Proto $scheme; # 转发协议 }
  7. #乾坤堂主站 location / { include enable-php-72.conf; index app.php; try_files $uri @rewriteapp; } location @rewriteapp { rewrite ^(.*)$ /app.php/$1 last; } #乾坤堂论坛 location /bbs { include enable-php-82.conf; try_files $uri $uri/ /bbs/index.php; } location ~^(/bbs/page/).*(.php)$ { include enable-php-82.conf; try_files $uri $uri/ /bbs/index.php; } # location /bbs/api/ { # include enable-php-82.conf; # if (!-e $request_filename){ # rewrite ^/bbs/api/(.*)$ /bbs/api/index.php; # } # } location /bbs/api/ { include enable-php-82.conf; try_files $uri $uri/ /bbs/api/index.php; } #乾坤堂论坛重定向到新地址(/bbs) location /forum/ { rewrite ^/forum/(.*)$ /bbs/forum/$1 permanent; } location /forums/ { rewrite ^/forums/(.*)$ /bbs/forums/$1 permanent; } location /topic/ { rewrite ^/topic/(.*)$ /bbs/topic/$1 permanent; } location /files/ { rewrite ^/files/(.*)$ /bbs/files/$1 permanent; } location /blogs/ { rewrite ^/blogs/(.*)$ /bbs/blogs/$1 permanent; } location /gallery/ { rewrite ^/gallery/(.*)$ /bbs/gallery/$1 permanent; } location /store/ { rewrite ^/store/(.*)$ /bbs/store/$1 permanent; } location /subscriptions/ { rewrite ^/subscriptions/(.*)$ /bbs/subscriptions/$1 permanent; } location /profile/ { rewrite ^/profile/(.*)$ /bbs/profile/$1 permanent; } location /topmembers/ { rewrite ^/topmembers/(.*)$ /bbs/topmembers/$1 permanent; } location /uploads/ { rewrite ^/uploads/(.*)$ /bbs/uploads/$1 permanent; } location /links/ { rewrite ^/links/(.*)$ /bbs/links/$1 permanent; } location /videos/ { rewrite ^/videos/(.*)$ /bbs/videos/$1 permanent; }
  8. Discouse常见问题持续更新中

    问题调试
    https://www.xxxx.chat/sidekiq/ (任务看板)
    https://www.xxxx.chat/logs/ (日志看板)
    https://www.xxxx.chat/safe-mode/(进入安全模式)
    删除重复值
    ./launcher enter app(进入容器)
    rails c(进入控制台)
    result = ActiveRecord::Base.connection.execute("SELECT * FROM post_hotlinked_media WHERE post_id = 67") (查询重复值)PostHotlinkedMedia.where(post_id: 67, url: 'bd419e11ddca94e73e9511cd77845384').first.destroy(删除重复值)修改域名
    ./launcher enter app(进入容器)
    discourse remap www.old.com www.new.com (更换域名)
    rake posts:rebake (重新编译)
  9. ./launcher enter app
    rails c
    admin_user = User.find_by(email: 'admin@example.com') 或 admin_user = User.find_by(username: 'admin')
    admin_user.email = 'newemail@example.com' (修改邮箱)
    admin_user.save (保存修改)
    admin_user.username = 'new_username' (修改用户名)
    admin_user.save (保存修改)
    admin_user.admin = true (将用户设置为管理员)
    admin_user.save (保存修改)
    其余仿此类操作就可以
    exit (退出控制台)
    …………………………………………………………………………………………


  10. 乾坤视频系统简要安装说明

    乾坤视频系统简要安装说明
    首先感谢购买此套源码
    环境要求:Linux/Apache/Nginx/PHP7.4+/Mysql5.7+ */NodeJS/
    扩展安装:PHP需安装fileinfo/exif/intl/calendar扩展,不装扩展会出现莫名错误和工作室404
    第一步:上传安装包至网站根目录并解压
    第二步:导入数据库文件至数据库中(根目录中的qiankun_tv.sql)
    第三步:创建站点数据库并配置好根目录的config.php文件
    $sql_db_host = "localhost";(9-18行)
    $sql_db_user = "你的数据库用户名";
    $sql_db_pass = "你的数据库密码";
    $sql_db_name = "你的数据库名称";
    $site_url = "你的域名";
    第四步:配置伪静态(如果是Nginx的话需要手动配置一下,Apache则不用)
    Nginx伪静态如下(Nginx和Apache伪静态配置文件在根目录中也):
    location / { if (!-e $request_filename){ rewrite ^/$ /index.php?link1=home; } rewrite ^/@([^\/]+)(\/|)$ /index.php?link1=timeline&id=$1; if (!-e $request_filename){ rewrite ^/([^\/]+)(\/|)$ /index.php?link1=$1; } } location /reset { rewrite ^/reset-password/([^\/]+)(\/|)$ /index.php?link1=reset-password&code=$1; } location /confirm { rewrite ^/confirm/(.*)/(.*)$ /index.php?link1=confirm&code=$1&email=$2; } location /finish { rewrite ^/finish/(.*)/(.*)$ /index.php?link1=finish&code=$1&email=$2; } location = /two_factor_login { rewrite ^(.*)$ /index.php?link1=two_factor_login; } location = /two_factor_submit { rewrite ^(.*)$ /index.php?link1=two_factor_submit; } location /v { rewrite ^/v/(.*)$ /index.php?v=$1; } location /api { rewrite ^/api/v(([0-9])([.][0-9]+))(\/|)$ /api.php?v=$1; } location /admin { rewrite ^/admin-cp$ /admincp.php; rewrite ^/admin-cp/(.*)$ /admincp.php?page=$1; } location /admin-cdn/ { alias /admin-panel/; } location /videos { rewrite ^/videos/category/(.*)/rss(\/|)$ /index.php?link1=videos&page=category&id=$1&feed=rss; rewrite ^/videos/category/(.*)/(.*)$ /index.php?link1=videos&page=category&id=$1&sub_id=$2; rewrite ^/videos/category/(.*)$ /index.php?link1=videos&page=category&id=$1; rewrite ^/videos/(.*)/rss(\/|)$ /index.php?link1=videos&page=$1&feed=rss; rewrite ^/videos/(.*)$ /index.php?link1=videos&page=$1; } location /articles { rewrite ^/articles(\/|)$ /index.php?link1=articles; rewrite ^/articles/category/(.*)(\/|)$ /index.php?link1=articles&category_id=$1; rewrite ^/articles/read/(.*)(\/|)$ /index.php?link1=read&id=$1; } location /aj { rewrite ^/aj/([^/.]+)/?$ /ajax.php?type=$1; rewrite ^/aj/([^/.]+)/([^/.]+)/?$ /ajax.php?type=$1&first=$2; rewrite ^/aj/([^/.]+)/([^/.]+)/([^/.]+)/?$ /ajax.php?type=$1&first=$2&second=$3; } location /edit { rewrite ^/edit-video/(.*)?$ /index.php?link1=edit-video&id=$1; } location /video_text { rewrite ^/video_text/(.*)?$ /index.php?link1=video_text&id=$1; } location /watch { rewrite ^/watch/([^\/]+)(\/|)?$ /index.php?link1=watch&id=$1; rewrite ^/watch/([^\/]+)/list/([^\/]+)(\/|)?$ /index.php?link1=watch&id=$1&list=$2; } location /embed { rewrite ^/embed/(.*)?$ /index.php?link1=embed&id=$1; } location /resend { rewrite ^/resend/(.*)/(.*)?$ /index.php?link1=resend&id=$1&u_id=$2; } location /redirect { rewrite ^/redirect?$ /index.php?link1=redirect; rewrite ^/redirect/(.*)?$ /index.php?link1=redirect&id=$1; } location /settings { rewrite ^/settings$ /index.php?link1=settings; rewrite ^/settings/(.*)/(.*)$ /index.php?link1=settings&page=$1&user=$2; rewrite ^/settings/(.*)$ /index.php?link1=settings&page=$1; } location /terms { rewrite ^/terms/([^\/]+)(\/|)$ /index.php?link1=terms&type=$1; } location /go_pro { rewrite ^/go_pro(\/|)$ /index.php?link1=go_pro; } location /ads { rewrite ^/ads(\/|)$ /index.php?link1=ads; rewrite ^/ads/create(\/|)$ /index.php?link1=create_ads; rewrite ^/ads/edit/(\d+)(\/|)$ /index.php?link1=edit_ads&id=$1; rewrite ^/ads/analytics/(\d+)(\/|)$ /index.php?link1=ads_analytics&id=$1; } location /contact { rewrite ^/contact-us(\/|)$ /index.php?link1=contact; } location /messages { rewrite ^/messages$ /index.php?link1=messages; rewrite ^/messages/(.*)$ /index.php?link1=messages&id=$1; } location /view_analytics { rewrite ^/view_analytics/(.*)$ /index.php?link1=view_analytics&id=$1; } location /video_studio { rewrite ^(.*)$ /index.php?link1=video_studio; } location = /comments { rewrite ^(.*)$ /index.php?link1=comments; } location = /dashboard { rewrite ^(.*)$ /index.php?link1=dashboard; } location = /popular_channels { rewrite ^(.*)$ /index.php?link1=popular_channels; } location /shorts { rewrite ^/shorts/(.*)$ /index.php?link1=shorts&id=$1; } location = /shorts { rewrite ^(.*)$ /index.php?link1=shorts; } location = /create_article { rewrite ^(.*)$ /index.php?link1=create_article; } location = /my_articles { rewrite ^(.*)$ /index.php?link1=my_articles; } location /edit_articles { rewrite ^/edit_articles/(.*)?$ /index.php?link1=edit_articles&id=$1; } location = /age_block { rewrite ^(.*)$ /index.php?link1=age_block; } location /site { rewrite ^/site-pages/(.*)$ /index.php?link1=site-pages&page_name=$1; } location /post { rewrite ^/post/(.*)(\/|)$ /index.php?link1=post&id=$1; } location /edit_activity { rewrite ^/edit_activity/(.*)(\/|)$ /index.php?link1=edit_activity&id=$1; } 第四步:访问你的域名即可打开网站
    进入网站后请先登陆账号(默认账号:admin 默认密码:admin123)
    登陆后即可访问地址进入后台(后台地址:域名/admin-cp)
    至此安装已完成!
    备注一:(安装完成并测试好后请删除演示数据,谢谢!)
    备注二:(FFMPEG转码功能开启会占用大量的服务器资源,请根据情况开启!)
    安装过程中有任何问题请联系QQ:1859389
  11. Linux服务器原生安装Answer问答程序

    准备工作
    下载 Golang 从官方网站下载并安装 Go 语言, 按默认设置安装即可。
    Clone Answer 项目 确保你已经克隆了 Apache Answer 到本地,如还未克隆,请阅读 Apache Answer 前端配置指南。
    一、初始化项目
    在 Answer 项目根目录打开命令行终端运行以下命令。
    go mod download go run cmd/answer/main.go init -C ./answer-data 注:如果第一条跑不出来可先跑第二条,运行时间可能较长,请耐心等待。
    看到 [SUCCESS] 即运行成功,注意此时不要关闭该程序。在网页输入所提示的网址:http://localhost:80/install/,打开并进行下一步安装。
    注:如果打开网址找不到此localhost页面,尝试先运行以下命令再重试
    cd ./ui pnpm pre-install pnpm install pnpm build cd .. 二、安装界面
    打开 http://localhost:80/install/ 将看到以下界面,第一步选择语言。
    2.1 配置数据库
    你可以使用自己的数据库软件创建 Answer 数据库 Apache Answer 支持 MySQL、PostgreSQL 和 SQLite 作为数据库后端。环境最小的是 SQLite,不需要任何额外配置。 如果要使用 MySQL 或 PostgreSQL,则需要先设置数据库,然后在此步骤中配置数据库连接。
    本文将以 MySQL 为例进行说明。
    创建数据库
    在MySQL 命令行中创建一个名为 answer 的数据库:
    配置数据库连接
    访问 http://localhost:80/install/,在安装界面中输入你的数据库连接信息:
    User name: root
    Database host: 127.0.0.1:3306
    Password: 你的数据库密码
    2.2 创建配置文件
    在安装界面中,按照提示创建 config.yaml 文件。
    2.3 设置网页信息和管理员账号
    请记住网站URL(如http://localhost)以及管理员账号信息密码,方便后续登陆。
    2.4 完成安装

    三、运行后端
    回到命令行终端,在answer项目根目录运行以下命令启动后端服务器 。
    go run cmd/answer/main.go run -C ./answer-data 四、验证安装
    在浏览器中访问你设置的网站 URL(例如:http://localhost),登陆你的管理员账号,如果看到一下页面,即配置成功。
  12. 私有云搭建 Discourse 论坛系统

    1. 前期准备
    服务器/域名/SMTP邮箱/
    登录到系统:
    ssh discourse@192.168.0.175 sudo apt update sudo apt upgrade -y
    2. 准备部署文件
    sudo -s
    mkdir /var/discourse # 创建/var/discourse目录,所有与Discourse相关的文件都在此目录下。
    git clone https://github.com/discourse/discourse_docker.git /var/discourse #将官方Discourse Docker Image复制到/var/discourse cd /var/discourse ls
    3. 配置和引导Discourse
    从这里,您可以启动安装脚本。
    cd /var/discourse
    ./discourse-setup
    您将被问到以下问题:
    Discourse的主机名?
    输入您要用于Discourse的主机名,例如,discourse.test.com,其中discourse.test.com可以用您的域名替换。您需要使用一个域名,因为发送电子邮件时不能用IP地址。
    管理员帐户的电子邮件地址?选择要用于Discourse管理员帐户的电子邮件地址。这个电子邮件地址可以与您的Discourse域名完全无关,可以是您的电子邮件地址。
    请注意,当第一个用户注册该电子邮件时,此电子邮件地址将默认成为Discourse管理员。稍后当您从其网络控制面板设置Discourse时,您还需要此电子邮件地址。
    Hostname for your Discourse? [discourse.example.com]: Email address for admin account(s)? [me@example.com,you@example.com]: SMTP server address? [smtp.example.com]: SMTP port? [587]: SMTP user name? [user@example.com]: SMTP password? [pa$$word]: Let’s Encrypt account email? (ENTER to skip) [me@example.com]:
    这里需要您填写您的邮箱相关信息,您可以参考您邮箱的相关设置。
    最后,系统会要求您确认刚刚输入的所有设置。确认设置后,脚本将生成一个调用的配置文件app.yml,然后启动引导。
    注意:如果您需要在引导后更改或修复这些设置,请编辑/containers/app.yml文件并运行./launcher rebuild app否则,您的更改将不会生效。
    引导需要2-8分钟,之后将会运行。现在,让我们继续创建一个管理员帐户。
    4. 注册管理员帐户
    在您的浏览器中访问您的Discourse域名,你将看到下面的页面。

    如果您收到502 Bad Gateway错误,请等一两分钟然后刷新重试,Discourse可能尚未完成安装。
    页面加载时,单击蓝色注册按钮。您将看到一个名为“注册管理员帐户”的页面,其中包含以下字段:
    电子邮件:从下拉菜单中选择您之前提供的电子邮件地址。
    用户名:选择用户名。
    密码:设置一个强密码。
    然后单击表单上的蓝色“注册”按钮提交。您将看到一个对话框,显示确认您的电子邮件。检查收件箱中的确认电子邮件。如果您没有收到,请尝试单击“重新发送激活电子邮件”按钮。
    注册管理员帐户后,安装向导将启动并引导您完成Discourse的基本配置。您现在可以浏览它或单击“稍后”跳过。
    有时候由于邮件设置问题无法收到注册邮件可以如下操作:
    后台创建admin账户
    1.在cd /var/discourse 下执行:
    ./launcher enter app #进入容器 rake admin:create Email: duanshuaixing@gmail.com Password: Repeat password: Do you want to grant Admin privileges to this account? (Y/n) Y
    创建成功,请记住设置的密码和邮箱,然后再次打开论坛网址,发现已经进入了论坛首页
    5. 修改配置文件
    ## this is the all-in-one, standalone Discourse Docker container template ## ## After making changes to this file, you MUST rebuild ## /var/discourse/launcher rebuild app ## ## BE *VERY* CAREFUL WHEN EDITING! ## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT! ## visit http://www.yamllint.com/ to validate this file as needed templates: - "templates/postgres.template.yml" - "templates/redis.template.yml" - "templates/web.template.yml" - "templates/web.ratelimited.template.yml" ## Uncomment these two lines if you wish to add Lets Encrypt (https) # - "templates/web.ssl.template.yml" ## 没有开启 支持https # - "templates/web.letsencrypt.ssl.template.yml" ## 没有开启 支持https ## which TCP/IP ports should this container expose? ## If you want Discourse to share a port with another webserver like Apache or nginx, ## see https://meta.discourse.org/t/17247 for details expose: - "80:80" # http - "443:443" # https - "25:25" # SMTP params: db_default_text_search_config: "pg_catalog.english" ## Set db_shared_buffers to a max of 25% of the total memory. ## will be set automatically by bootstrap based on detected RAM, or you can override db_shared_buffers: "4096MB" ## can improve sorting performance, but adds memory usage per-connection #db_work_mem: "40MB" ## Which Git revision should this container use? (default: tests-passed) #version: tests-passed env: LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LANGUAGE: en_US.UTF-8 EMBER_CLI_PROD_ASSETS: 1 # DISCOURSE_DEFAULT_LOCALE: en ## How many concurrent web requests are supported? Depends on memory and CPU cores. ## will be set automatically by bootstrap based on detected CPUs, or you can override UNICORN_WORKERS: 8 ## TODO: The domain name this Discourse instance will respond to ## Required. Discourse will not work with a bare IP number. DISCOURSE_HOSTNAME: discourse.test.com ## Uncomment if you want the container to be started with the same ## hostname (-h option) as specified above (default "$hostname-$config") #DOCKER_USE_HOSTNAME: true ## TODO: List of comma delimited emails that will be made admin and developer ## on initial signup example 'user1@example.com,user2@example.com' DISCOURSE_DEVELOPER_EMAILS: 'Discourse@test.com' ## TODO: The SMTP mail server used to validate new accounts and send notifications # SMTP ADDRESS, username, and password are required # WARNING the char '#' in SMTP password can cause problems! DISCOURSE_SMTP_ADDRESS: mail.test.com DISCOURSE_SMTP_PORT: 25 # DISCOURSE_SMTP_USER_NAME: # DISCOURSE_SMTP_PASSWORD: #DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true) DISCOURSE_SMTP_ENABLE_START_TLS: false # (optional, default true) #DISCOURSE_NOTIFICATION_EMAIL: noreply@discourse.test.com DISCOURSE_NOTIFICATION_EMAIL: noreply@test.com # DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none # DISCOURSE_SMTP_AUTHENTICATION: login ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate LETSENCRYPT_ACCOUNT_EMAIL: me@example.com ## The http or https CDN address for this Discourse instance (configured to pull) ## see https://meta.discourse.org/t/14857 for details #DISCOURSE_CDN_URL: https://discourse-cdn.example.com ## The maxmind geolocation IP address key for IP address lookup ## see https://meta.discourse.org/t/-/137387/23 for details #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456 ## The Docker container is stateless; all data is stored in /shared volumes: - volume: host: /var/discourse/shared/standalone guest: /shared - volume: host: /var/discourse/shared/standalone/log/var-log guest: /var/log ## Plugins go here ## see https://meta.discourse.org/t/19157 for details hooks: after_code: - exec: cd: $home/plugins cmd: - git clone https://github.com/discourse/docker_manager.git - git clone https://github.com/jonmbake/discourse-ldap-auth.git - git clone https://github.com/discourse/discourse-solved.git - git clone https://github.com/discourse/discourse-math.git - git clone https://github.com/discourse/discourse-voting.git - git clone https://github.com/discourse/discourse-push-notifications.git - git clone https://github.com/discourse/discourse-spoiler-alert.git - git clone https://github.com/discourse/discourse-graphviz.git - git clone https://github.com/unfoldingWord-dev/discourse-mermaid.git - git clone https://github.com/discourse/discourse-checklist.git - git clone https://github.com/discourse/discourse-assign.git - git clone https://github.com/discourse/discourse-linkify-words.git - git clone https://github.com/communiteq/discourse-suppress-category-from-latest.git - git clone https://github.com/discourse/discourse-prometheus.git - git clone https://github.com/discourse/discourse-docs.git - git clone https://github.com/discourse/discourse-docs-card-filter.git - git clone https://github.com/discourse/discourse-translator.git ## Any custom commands to run after building run: - exec: echo "Beginning of custom commands" ## If you want to set the 'From' email address for your first registration, uncomment and change: ## After getting the first signup email, re-comment the line. It only needs to run once. # - exec: rails r "SiteSetting.notification_email='noreply@discuss.streamcomputing.com - exec: cmd: - sed -i 's/MinProtocol = TLSv1.2/\#MinProtocol = TLSv1.2/' /etc/ssl/openssl.cnf # 这个注释TLS 配置, 否则SMTP邮件协议不match,发不了邮件 - sed -i 's/CipherString = DEFAULT\@SECLEVEL=2/\#CipherString = DEFAULT\@SECLEVEL=2/' /etc/ssl/openssl.cnf#这个注释TLS 配置 - exec: echo "End of custom commands" 更改或修复这些设置,请编辑 /var/discourse/containers/app.yml文件并运行./launcher rebuild app否则,您的更改将不会生效。
    6. 支持https
    修改app.yml
    /var/discourse/containers/app.yml内修改打开这个注释 - “templates/web.ssl.template.yml”
    生成证书并导入证书
    生成证书参考Certbot自签Let’s Encrypt证书
    mkdir -p /var/discourse/shared/standalone/ssl/ cp ssl.crt /var/discourse/shared/standalone/ssl/ssl.crt cp ssl.key /var/discourse/shared/standalone/ssl/ssl.key
    重建app
    ./launcher rebuild app
    开启强制https
    重启应用
    ./launcher restart app
    安装插件
    ./launcher enter app cd /var/www/discourse/ rake plugin:install repo=https://github.com/unfoldingWord-dev/discourse-mermaid.git rake plugin:install repo=https://github.com/albertchan/discourse-aliyun-oss.git rake assets:precompile exit ./launcher restart app
    备份和恢复
    备份
    恢复,下载的备份导入到另外一个环境
    mkdir -p /var/discourse/shared/standalone/backups/default scp root@192.168.0.175:/var/discourse/shared/standalone/backups/discourse-2021-04-21-151816-v20210328233843.tar.gz /var/discourse/shared/standalone/backups/default
    cd /var/discourse ./launcher enter app discourse enable_restore discourse restore discourse-2021-04-21-151816-v20210328233843.tar.gz
    9. 卸载
    cd /var/discourse ./launcher destroy app rm -rf /var/discourse/
    10. FAQ
    构建项目git clone慢可以通过给容器配置vpn或者代理方式解决,建议sshuttle 方式,比较方便
    docker配置代理
    mkdir ~/.docker cat ~/.docker/config.json { "proxies": { "default": { "httpProxy": "http://47.57.14.232:8080", "httpsProxy": "http://47.57.14.232:8443", "noProxy": "127.0.0.1,localhost,172.17.0.0/16,192.168.0.0/24,gems.ruby-china.com } } }
    systemctl daemon-reload systemctl restart docker
    cd /var/discourse ./launcher bootstrap app ./launcher start app
  13. Docker镜像源站最新

    DockerHub 镜像仓库 镜像加地址 bestcfipas镜像服务 https://docker.registry.cyou   https://docker-cf.registry.cyou zero_free镜像服务 https://docker.jsdelivr.fyi   https://dockercf.jsdelivr.fyi   https://dockertest.jsdelivr.fyi docker proxy https://dockerpull.com  (已测试OK) docker proxy https://dockerproxy.cn Docker镜像加速站 https://hub.uuuadc.top   https://docker.1panel.live   https://hub.rat.dev DockerHub 镜像加速代理 https://docker.anyhub.us.kg   https://docker.chenby.cn   https://dockerhub.jobcher.com 镜像使用说明 https://dockerhub.icu Docker镜像加速站 https://docker.ckyl.me 镜像使用说明 https://docker.awsl9527.cn 镜像使用说明 https://docker.hpcloud.cloud DaoCloud 镜像站 https://docker.m.daocloud.io AtomHub 可信镜像仓库平台 (只包含基础镜像,共336个) https://atomhub.openatom.cn
  14. 只需要在core_member_ranks 数据表中添加缺失的字段即可
    ALTER TABLE core_member_ranks ADD rank_icon VARCHAR(255) DEFAULT NULL; ALTER TABLE core_member_ranks ADD rank_shape VARCHAR(255) DEFAULT 'circle', ALTER TABLE core_member_ranks ADD rank_sides INT DEFAULT 5, ALTER TABLE core_member_ranks ADD rank_rotation INT DEFAULT 0; ALTER TABLE core_member_ranks ADD COLUMN rank_background VARCHAR(7) DEFAULT NULL; ALTER TABLE core_member_ranks ADD COLUMN rank_border VARCHAR(7) DEFAULT NULL; ALTER TABLE core_member_ranks ADD COLUMN rank_foreground VARCHAR(7) DEFAULT NULL;


  15. 在 Debian 中,locale -a 命令会列出系统中所有已生成的 locale。要显示所有可用的多语言 locale,你可以执行以下步骤:
    确保安装 locales 包: 确保 locales 包已安装:
    sudo apt install locales 编辑 locale.gen 文件: 打开 /etc/locale.gen 文件,确保文件中包含你想要的所有语言条目。可以使用文本编辑器打开:
    sudo nano /etc/locale.gen 在文件中,取消注释(去掉行首的 #)你想要的语言条目,比如:
    en_US.UTF-8 UTF-8 zh_CN.UTF-8 UTF-8 fr_FR.UTF-8 UTF-8 de_DE.UTF-8 UTF-8 生成所有 locale: 保存并关闭文件后,运行以下命令以生成指定的 locale:
    sudo locale-gen 查看已生成的 locale: 运行以下命令,查看所有已生成的 locale:
    locale -a 重启服务或系统: 如果需要,重启服务或系统,以确保更改生效。
    reboot
  16. 1. 修改 app.yml 邮箱配置
    Discourse 的邮件配置通常在容器的 app.yml 文件中。你可以通过以下步骤修改这个文件:
    使用 SSH 连接到你的服务器。
    编辑 Discourse 的配置文件:
    cd /var/discourse nano containers/app.yml找到以下部分,并修改相关的邮箱配置参数:
    DISCOURSE_SMTP_ADDRESS: smtp.example.com DISCOURSE_SMTP_PORT: 587 DISCOURSE_SMTP_USER_NAME: your_email@example.com DISCOURSE_SMTP_PASSWORD: your_password DISCOURSE_SMTP_ENABLE_START_TLS: true确保你根据实际的 SMTP 服务器信息填写这些值。

    2. 仅编译邮箱配置
    修改完邮箱配置后,你不需要完全重建整个 Discourse 容器,而是可以使用以下命令重新加载配置:
    cd /var/discourse ./launcher destroy app ./launcher start app通过这个命令,你只会重启容器并应用新的配置,而不会完全重新编译 Discourse。

    3. 验证配置
    重启后,你可以进入 Discourse 后台,测试邮箱配置是否正确。你可以通过以下步骤来测试:
    登录 Discourse 管理后台(/admin)。
    导航到 设置 -> 邮件,点击 发送测试邮件 来验证新配置是否工作正常。
    如果一切设置正确,应该可以顺利发送测试邮件。
    这样,你就能只编译和生效修改过的邮箱配置,而不重新编译整个 Discourse 实例。
  17. 报错如图显示:

     
    问题解决:
    修改app.yml文件,新增一条配置代码引入国内镜像源配置文件
    - "templates/web.china.template.yml" 如果出现github.com报错的话需要设置一下代理
    vim /etc/profile # 添加自己实际情况,添加以下内容 export https_proxy=http://user:passwd@IP:58963 export all_proxy=socks5://IP:38476 # 执行生效 source /etc/profile  
    配置socks5代理
    git config --global http.proxy socks5 127.0.0.1:7890 git config --global https.proxy socks5 127.0.0.1:7890 配置http代理
    git config --global http.proxy 127.0.0.1:7890 git config --global https.proxy 127.0.0.1:7890 取消http代理
    git config --global --unset http.proxy git config --global --unset https.proxy  
  18. 1. 准备工作
    在开始之前,你需要先准备好以下工具和环境:
    已安装MySQL数据库 已启用二进制日志(binlog) 已安装mysqlbinlog工具 2. 查找binlog文件
    首先,你需要找到指定时间点的binlog文件。可以使用如下命令查看当前数据库的binlog文件列表:
    mysqlbinlog --base64-output=DECODE-ROWS --verbose --help 其中,
    --base64-output=DECODE-ROWS 用于解码binlog文件,
    --verbose 用于显示详细信息,
    --help 用于查看帮助信息。执行上述命令后,会输出类似如下内容:
    -rw-r----- 1 mysql mysql  1075 Sep 17 14:50 mysql-bin.000001 -rw-r----- 1 mysql mysql  1075 Sep 17 14:50 mysql-bin.000002 -rw-r----- 1 mysql mysql  1075 Sep 17 14:50 mysql-bin.000003 从以上输出中,可以找到目标时间点对应的binlog文件。
     
    3. 提取指定时间的binlog
    使用mysqlbinlog工具提取指定时间点的binlog文件。将下面的命令中的<binlog_filename>替换为实际的binlog文件名,<start_time>和<end_time>替换为回滚的时间范围:
    mysqlbinlog --start-datetime="<start_time>" --stop-datetime="<end_time>" <binlog_filename> 4. 转换为SQL
    将提取的binlog内容转换为SQL语句。使用如下命令:
    mysqlbinlog --base64-output=DECODE-ROWS <binlog_file> > output.sql 5. 生成转存SQL脚本
    根据需要生成转存SQL脚本。可以使用文本编辑器打开output.sql文件,根据需要进行修改和处理。例如,可以删除不需要的SQL语句,增加一些注释等。
     
    show variables like '%log_bin%'; show variables like '%datadir%';  
  19. Linux下解决访问github慢的问题

    解决方案:
    修改本地host文件,增加配置内容,绕过域名解析,达到加速的目的。
    输入以下命令修改host文件:
    sudo vim /etc/hosts

    在127.0.0.1 localhost下面添加:
    199.232.69.194          github.global.ssl.fastly.net 140.82.113.3            github.com 185.199.108.154         github.githubassets.com 

    重启 systemd-resolved 服务,刷新DNS:
    sudo systemctl restart systemd-resolved
    命令执行报错,请搜索自己版本的系统相应的刷新DNS命令。
    特别说明(一定要看!!!):
    Github的IP地址是不断变化的,如果发现网站打不开了,可以获取新的IP地址修改hosts里面的内容,方式如下:
    在网站https://ip.tool.chinaz.com/ 输入你要解析的域名
    例如:github.com的IP获取方式,在输入框输入以下内容:
    github.com github.githubassets.com github.global.ssl.fastly.net 

    获取对应的IP地址,替换hosts里的内容。
    github常用相关域名如下(发帖当日获取的IP),大家可以直接复制黏贴到自己的hosts里面,别忘了刷新一下DNS
    199.232.69.194              github.global.ssl.fastly.net 140.82.113.3                github.com 185.199.108.154             github.githubassets.com 140.82.113.21               central.github.com 185.199.108.133             desktop.githubusercontent.com 185.199.108.153             assets-cdn.github.com 185.199.108.133             camo.githubusercontent.com 185.199.108.133             github.map.fastly.net 140.82.114.4                gist.github.com 185.199.108.153             github.io 140.82.112.5                api.github.com