Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

r.cnpmjs.org 和 registry.npm.taobao.org 在 kappa 后面无法使用 #581

Closed
uzcc opened this issue Jan 31, 2015 · 16 comments
Closed

r.cnpmjs.org 和 registry.npm.taobao.org 在 kappa 后面无法使用 #581

uzcc opened this issue Jan 31, 2015 · 16 comments
Assignees
Labels
Milestone

Comments

@uzcc
Copy link

uzcc commented Jan 31, 2015

{
    "servers": [
        {
            "host": "127.0.0.1",
            "port": "7000"
        }
    ],
    "plugins": {
        "kappa": {
            "vhost": "npmcc.creditcloud.com",
            "rewriteTarballs": true,
            "paths": [
                "http://127.0.0.1:7001/",
                "https://registry.npm.taobao.org/",
                "https://registry.npmjs.org/"
            ]
        }
    }
}

以上是我们的 kappa.json,不知道是不是因为 #576 的原因,对于 http://127.0.0.1:7001 404 的 module,以上配置的 kappa 在带 Accept-Encoding: gzip 的请求时会出现 500,而删掉 taobao.org 这一行让 kappa 反向代理到 npmjs.org 则不会 500.

现在我们在前面的 nginx 反向代理中加了一个 Accept-Encoding: identity 解决了此问题

server {
  listen 80;
  server_name npmcc.creditcloud.com;

  location / {
    proxy_pass http://127.0.0.1:7000/;
    proxy_set_header Accept-Encoding identity;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
@fengmk2
Copy link
Member

fengmk2 commented Jan 31, 2015

kappa 不支持 gzip?我现在配置是没错的啊,既然 kappa 的请求带了 Accept-Encoding: gzip,那么肯定会返回 gzip 的 json 数据

@dead-horse
Copy link
Member

npm 官方是不会返回 gzip 的...

@fengmk2
Copy link
Member

fengmk2 commented Jan 31, 2015

npm cli 支持 gzip 的

@uzcc
Copy link
Author

uzcc commented Feb 1, 2015

有可能就是 kappa 不支持 gzip 的原因。你们最近的改变就是添加了 gzip 吗?

@fengmk2
Copy link
Member

fengmk2 commented Feb 1, 2015

是的,很多 npm 包 meta 信息超过1MB 了,需要加 gzip 优化,要不然带宽跟速度都吃不消。

@fengmk2
Copy link
Member

fengmk2 commented Feb 1, 2015

@uzcc 去给 kappa 提交 pr 吧

@fengmk2
Copy link
Member

fengmk2 commented Feb 2, 2015

@uzcc 使用 http://registry.npm.taobao.org 阿里云的http负载均衡不支持gzip…… 你可以先用这个

@uzcc
Copy link
Author

uzcc commented Feb 2, 2015

@fengmk2 我现在 nginx Accept-Encoding: identity 到 upstream 然后 nginx 设置

gzip_proxied no-cache;
gzip_types application/json;

这样倒是可以解决问题

@uzcc
Copy link
Author

uzcc commented Feb 2, 2015

krakenjs/kappa#97

@fengmk2
Copy link
Member

fengmk2 commented Feb 2, 2015

感觉你可以直接用cnpm搭一个私有npm好了,开启同步已存在的模块模式,也不需要全量同步

Sent from my iPhone

On Feb 2, 2015, at 2:32 PM, undoZen at CreditCloud [email protected] wrote:

@fengmk2 我现在 nginx Accept-Encoding: identity 到 upstream 然后 nginx 设置

gzip_proxied no-cache;
gzip_types application/json;
这样倒是可以解决问题


Reply to this email directly or view it on GitHub.

@uzcc
Copy link
Author

uzcc commented Feb 2, 2015

我试过,但是已存在的模块是包括所有版本吧,仍然会非常大。所以现在完全关掉同步了,只用私有registry+kappa

@fengmk2
Copy link
Member

fengmk2 commented Feb 2, 2015

看来可以加上这个功能,不做任何同步,非私有库全部走代理模式

Sent from my iPhone

On Feb 2, 2015, at 7:07 PM, undoZen at CreditCloud [email protected] wrote:

我试过,但是已存在的模块是包括所有版本吧,仍然会非常大。所以现在完全关掉同步了,只用私有registry+kappa


Reply to this email directly or view it on GitHub.

@undoZen
Copy link

undoZen commented Feb 2, 2015

不错

@fengmk2
Copy link
Member

fengmk2 commented Feb 2, 2015

@undoZen @uzcc #590 可以试试这个分支

@fengmk2 fengmk2 added the feat label Feb 2, 2015
@fengmk2 fengmk2 added this to the 2.0 milestone Feb 2, 2015
@fengmk2 fengmk2 self-assigned this Feb 2, 2015
@jincdream
Copy link

意思是可以搭建cnpm, 然后可以加上这个功能:不做任何同步,非私有库全部走代理模式?

@fengmk2
Copy link
Member

fengmk2 commented Oct 15, 2015

配置 syncModel = "none" 即可。 @jincdream 就是你说的这个意思。

@fengmk2 fengmk2 closed this as completed Oct 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants