爱意满满的作品展示区。
pubby

做了个有点小众的轮子: Squid Url Rewriter

  •  
  •   pubby · Jul 26, 2016 · 2861 views
    This topic created in 3604 days ago, the information mentioned may be changed or developed.

    @GitHub

    起因:

    几台文件服务器前面放了个 squid 缓存服务,并且有一些 url 需要 rewrite 处理。

    以前一直用 squirm ,不过它太老了几年不更新,不支持并发,也不支持最新的 squid redirector 协议

    高峰期经常因为 squrim 进程不足崩溃(已经开到几百个 squirm 了 -_- )

    网上没找到简单好用的,自己简单写了一个

    特点:

    1. 只做 rewrite 和 redirect(302,301)
    2. 支持并发
    3. 需要 Squid-3.4+
    4. 配置文件 reload (通过 SIGHUP 信号)
    2 replies    2016-07-27 10:42:22 +08:00
    ericFork
        1
    ericFork  
       Jul 27, 2016
    ……你后面接个 nginx 就行了
    pubby
        2
    pubby  
    OP
       Jul 27, 2016   ❤️ 1
    @ericFork 对,有些服务后面确实还有 nginx

    不过这个 url rewrite 和 nginx 不太一样的地方是,匹配规则包括 host 部分

    比如可以给前端做跨域代理来访问一些无法跨域使用接口

    rewrite https?://([^/]+)/proxy/_/( https?)/(.*) $1://$2

    (需要把 squid 设为 accel 方式)


    http://mysite.com/proxy/_/http/othersite.com/non-cors-api.json
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3112 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 13:46 · PVG 21:46 · LAX 06:46 · JFK 09:46
    ♥ Do have faith in what you're doing.