HEX.PM 配置

UPYUN 已提供 HEX 的镜像,本帖中的源即将停用。请使用 https://hexpm.upyun.com

已经有官方版的教程了,戳 这里

不自带包管理器的语言都不是好语言

hex.pm 的资源使用 s3 fastly 存储,在国内使用受到很大影响。目前有两种方式访问: hex_mirror 和 http/https proxy

HEX_MIRROR

  1. 通过环境变量配置 hex_mirror
    HEX_MIRROR="https://hex.elixir-cn.org" mix deps.get
  2. 通过 hex 配置 hex_mirror
    mix hex.config mirror_url https://hex.elixir-cn.org
    

 

HTTP/HTTPS PROXY

  1. 通过环境变量配置 http_proxy
    http_proxy="http://127.0.0.1:8013" mix deps.get
  2. 通过 hex 配置 http_proxy
    mix hex.config http_proxy http://127.0.0.1:8013

Q & A

  • 为什么不做镜像站?
    官方认为 S3 的可用性足够,而且暂时没有性能压力,暂时不提供做 mirror 的接口,详见 elixir-lang-talk 的讨论。
  • hex.elixir-cn.org 是什么?
    这个 hex_cdn 是通过 nginx 配置在 digitalocean SFO 主机上的反向代理。
    此服务现在挂在家里路由器上,80 端口被 X,只能通过 https 访问。目前来看速度和稳定性尚可,如果路由器故障导致我 ssh 不回去,就只能等晚上回家的时候手动重启。
  • 为什么不使用 https?
    在等 letsencrypt,letsencrypt 开放后会在第一时间改用 https。