Files
qwqcode bad248534c docs: revise and add more examples
BREAKING CHANGE: The following top-level functions exported by the 'artalk' npm package have been deprecated: `Artalk.update`, `Artalk.reload`, and `Artalk.destroy`. These methods now require invocation on an instance created by either `Artalk.init` or `new Artalk`. Please utilize instance-level methods instead, such as `artalkInstance.update`. For more information, refer to  [the documentation](https://artalk.js.org/guide/frontend/import-framework.html). The update was implemented to enable the concurrent creation of multiple instances, adapting to situations where Vue components are simultaneously referenced across various pages. Initially, only a singular instance was permitted to mitigate memory leak concerns. However, this proved limiting for scenarios involving the caching of multiple component instances through 'keep-alive.' To better suit intricate SPA application needs, the choice was made to permit the creation of multiple independent instances. It's crucial to remember to manually invoke the `artalk.destroy` method when releasing components to avoid memory leaks (Issue #660).
2023-12-17 19:16:33 +08:00

2.3 KiB
Raw Permalink Blame History

反向代理

Caddy

/etc/caddy/Caddyfile

artalk.your_domain.com {
  tls /etc/caddy/ssl/cert.pem /etc/caddy/ssl/cert.key

  reverse_proxy http://localhost:23366 {
    header_up X-Forwarded-For {header.X-Forwarded-For}
  }
}

执行重载命令:

sudo systemctl reload caddy

Nginx

假定:

  • 你想绑定的域名是:artalk.your_domain.com
  • Artalk 本地地址:http://localhost:23366

以 Ubuntu 20.04 为例:

创建站点配置文件:

sudo vim /etc/nginx/sites-available/artalk.your_domain.com

编辑反向代理配置文件:

server
{
  listen 80;
  listen [::]:80;

  server_name artalk.your_domain.com;

  location / {
    proxy_redirect off;
    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://localhost:23366/;
  }
}

创建软链接启用站点:

sudo ln -s /etc/nginx/sites-available/artalk.your_domain.com /etc/nginx/sites-enabled/

验证配置文件是否有效:

sudo nginx -t

配置没有问题,重启 Nginx:

sudo systemctl restart nginx

配置前端:

Artalk.init({ server: "http://artalk.your_domain.com" })

::: tip 你还可以再套一层 CDN,然后加上 SSL

注意配置文件权限,以及反代目标 URL 可访问性

尤其是运行在 Docker 容器内的 artalk,注意检查 IP 和端口是否能够被 Nginx 正常访问 :::

Apache

需要启用反代模块 mod_proxy.c

<VirtualHost *:80>
    ServerName your_domain.xxx
    ServerAlias

    RewriteEngine On
    RewriteCond %{QUERY_STRING} transport=polling         [NC]
    RewriteRule /(.*)           http://localhost:23366/$1 [P]

    <IfModule mod_proxy.c>
        ProxyRequests Off
        SSLProxyEngine on
        ProxyPass / http://localhost:23366/
        ProxyPassReverse / http://localhost:23366/
    </IfModule>
</VirtualHost>

宝塔面板

首先创建一个站点 (例如 artalk.your_domain.com),然后点击站点的「设置」:

打开「反向代理」选项卡,点击「添加反向代理」,「目标 URL」填写 http://localhost:端口号(端口号与 Artalk 端口对应),「发送域名」填写 $host,如图: