← 所有迁移指南

竞争对手迁移指南

从 OpenResty 迁移到 Webship,无需盲切换。

将标准 NGINX 边缘行为移入 Webship,同时隔离 Lua 应用逻辑,以便进行明确的保留或重写决策。

适用于 Webship 1.5.3nginx.conf + Lua

在更改流量之前定义迁移边界。

首先只迁移 Webship 能够再现和验证的行为。在其替代品通过类似生产测试之前,保持应用程序认证、服务发现、脚本和专用缓存规则在现有源上。

先翻译最小的生产路径。

源片段标识了迁移概念;Webship 片段展示了目标形态。用针对您的环境验证过的值替换示例域、地址、证书、限制和健康路径。

代表性 OpenResty 配置
server {
  listen 443 ssl;
  server_name app.example.com;
  location / {
    access_by_lua_file /etc/openresty/auth.lua;
    proxy_pass http://127.0.0.1:8080;
  }
}
等效 Webship TOML
listen = "0.0.0.0:443"
workers = 4

[reverse_proxy]
enabled = true
tls_termination = true
connect_timeout_ms = 2000
max_retries = 0

[reverse_proxy.protocols]
h1 = true
h2 = true
h3 = true

[reverse_proxy.tls]
cert = "/etc/letsencrypt/live/app.example.com/fullchain.pem"
key = "/etc/letsencrypt/live/app.example.com/privkey.pem"

[[reverse_proxy.routes]]
domain = "app.example.com"
path_prefix = "/"
upstreams = ["127.0.0.1:8080", "127.0.0.1:8081"]
load_balancing = "weighted-peak-ewma"

[[reverse_proxy.upstreams]]
address = "127.0.0.1:8080"
protocol = "http1"
health_check_path = "/health"
health_check_interval_ms = 5000
health_check_timeout_ms = 1000

[[reverse_proxy.upstreams]]
address = "127.0.0.1:8081"
protocol = "http1"
health_check_path = "/health"
health_check_interval_ms = 5000
health_check_timeout_ms = 1000

[[reverse_proxy.policies]]
name = "default"
hosts = []
path_prefixes = ["/"]
methods = []
max_body_bytes = 1048576
total_timeout_ms = 30000

映射概念,而不是语法。

技术指令并不总是一一对应。使用此表查找等效的 Webship 配置区域,然后验证有效配置和运行时行为。

当前概念或指令Webship 配置目标
listener / frontendlisten + [reverse_proxy.protocols]
host + path matcher[[reverse_proxy.routes]]
backend / cluster / service[[reverse_proxy.upstreams]]
health probe[[reverse_proxy.upstreams]].health_check_*
request limits and timeouts[[reverse_proxy.policies]]
certificate and private key[reverse_proxy.tls] / [[sites]] cert + key

使用可逆的五步切换。

在 Webship 在代表流量上通过正确性、容量、安全性、可观测性和回滚检查之前,保持旧的监听器准备就绪。

  1. 1

    库存可观察行为

    记录监听器、域、路由、上游、证书、重写、认证、缓存规则、健康探测、限制和操作集成。

  2. 2

    翻译一个边界

    将一个主机或路由移入严格的 TOML。在单独替代方案被验证之前,保留供应商特定模块和应用逻辑在 Webship 后面。

  3. 3

    离线及本地验证

    运行 --check-config 和 --print-effective-config,检查被编辑的结果,在本地探测健康状况,并在启用 HTTP/3 时通过 TCP 和 UDP 使用 TLS。

  4. 4

    小范围真实流量(Canary 测试)

    向 Webship 发送一小部分可观察的流量。比较状态码、头信息、响应体、延迟、上游健康状况、缓存行为、日志和安全决策。

  5. 5

    推广并准备回滚

    在测量阶段增加流量。保持之前的目标健康并可立即路由,直到约定的观察窗口和负载门通过。

首先验证。通过路由回滚,而不是编辑实时内容。

验证候选文件,检查经过编辑的有效配置,并在更改流量之前探测私有侦听器。在观察窗口关闭之前,保留旧的二进制文件、配置、侦听器以及 DNS 或负载均衡目标。

/usr/local/bin/webship --check-config --config /etc/webship/production.toml
/usr/local/bin/webship --print-effective-config --config /etc/webship/production.toml
curl --http3-only --insecure https://127.0.0.1:443/health