Total Pageviews

Saturday 8 October 2016

通用的全站镜像反向代理程序-zmirror

The next-gen reverse proxy for full site mirroring. 通用的全站镜像反向代理,高度优化,特性丰富. Google镜像(无缝整合维基镜像)支持整个站群(含学术镜像/Gmail镜像/图片...), Twitter镜像/Instagram镜像完整支持, Youtube镜像除iOS外完整.
zmirror version zmirror Build Status zmirror unittest coverage zmirror Dependency Status
zmirror PRs Welcome zmirror Gitter
an http reverse proxy designed to automatically and completely mirror a website (such as google), support cache and CDN
一个Python反向HTTP代理程序, 用于快速、简单地创建别的网站的镜像, 自带本地文件缓存、CDN支持
比如国内可以访问的Google镜像/中文维基镜像
自带了几个配置文件: 比如 Google镜像(含学术/其他/中文维基) twitter镜像 Youtube镜像 instagram镜像 Facebook镜像
完整列表请看zmirror自带镜像配置文件
请在遵守当地相关法律法规的前提下使用本项目
本人拒绝为任何商业或非法目的提供任何技术支持
本项目仅为科研人员更方便地查询知识而创建, 请勿大范围传播

Demo

Screenshot

zmirror-screenshot-youtube-mirror--1080P
More screenshots are here: wiki-screenshots

一键部署脚本

builtin configs

Together with the program, provided several (almost) out-of-box configs

Google镜像 (整合中文维基镜像)

  • Gmail支持! (请访问 /gmail 并选择基础html视图)
  • 同时支持PC/手机
  • Google搜索与中文维基百科无缝结合
  • 大部分功能完全正常: 网页搜索/学术/图片/地图/新闻/图书/视频(搜索)/财经/APP搜索/翻译/网页快照/...
  • 目前暂时无法做到完美的登陆, 登录才可使用的功能部分无效
  • 不会被Google Ban掉
       传统的Nginx反代Google方案, 时间长了会被Google Ban掉, 或者弹图片验证码,
     这是由于Nginx反代镜像非常简陋, 用户的许多请求无法被正确发回到Google服务器,
     Google就会把真实的访问者当成是机器人.
       而zmirror比较完善, 用户的请求能全部发回到Google服务器, 不会被当成机器人

Twitter镜像

  • 支持PC站/手机 (两者需要以不同的域名部署, 详见配置)
  • 几乎所有功能完整可用, 大部分视频可以播放

Instagram镜像

  • 所有功能完整可用, 包括视频

Youtube镜像

  • 支持PC站/手机 (两者需要以不同的域名部署, 详见配置)
  • 视频播放、高清支持
  • 登陆支持、字幕支持
  • 小视频上传支持

Facebook镜像

  • 绝大部分功能可用, 但是不完整

自带其他的镜像配置文件

  • archive.org镜像
  • duckduckgo镜像
  • Dropbox镜像
  • Tumblr镜像
  • Economist(经济学人)镜像
  • thepiratebay(海盗湾)镜像
  • For more information, please see more_configs/readme.md

Requirements Install and Usage

Dependencies

Required

Optional

  • cChardet 编码检测
  • fastcache C implementation of Python 3 lru_cache
  • lru-dict A fast and memory efficient LRU dict for Python
Theoretically, any environment that can run Python3.4+, can also run zmirror
Nginx was not officially tested, but it should work pretty well.
However, due to my limited time, zmirror was only fully tested in:
Ubuntu14.04-x86_64 Apache2.4 wsgi python3.4
Ubuntu16.04-x86_64 Apache2.4 wsgi python3.5
windows10-x64 Apache2.4 wsgi python3.5-x64

Ubuntu14.04-x86_64 directly run (I mean, just execute python3 wsgi.py)
windows10-x64 directly run 

Installation and helloworld

This tutorial is mainly for your localhost demo test
If you want to deploy it to server, please complete the localhost demo first
  1. first, install python3
    Debian/Ubuntu apt-get install python3
    Windows go to python's homepage and download Python3.5 (or newer)
  2. install or upgrade flask and requests python3 -m pip install -U flask requests
  3. git clone https://github.com/aploium/zmirror
  4. copy the config_default.py to config.py
    Warning: You should NEVER EVER modify the config_default.py itself
    Please edit the config.py instead of config_default.py
    Unless your are developer.
    Settings in the config.py would override the default ones
  5. Execute it: python3 wsgi.py
  6. Open your browser and enter http://127.0.0.1/, you will see exactly the www.kernel.org, and you can click and browse around. everything of the *.kernel.org is withing the mirror.
  7. please see the following Deploy section

Deploy

请使用: 一键部署脚本
若希望手工部署, 可以看以下教程:
  1. 部署支持HTTPS和HTTP/2的zmirror镜像
  2. 在一台VPS部署多个zmirror镜像
Or, if you are familiar with flask, you can see flask's official deploy tutorial

Upgrade

  • cd YOUR_ZMIRROR_FOLDER and then git pull
    警告
    由于 v0.27 有很大的结构改动, 所以 v0.27 以内的 custom_func.py 如果有 from zmirror import 语句
    将无法在 v0.27 以后的版本工作
    解决办法是将 custom_func.py 中的 from zmirror import 修改为
    from zmirror.zmirror import 其他不需要改变
    若使用自带配置文件, 则只有Youtube和Twitter受影响

Feature

  1. Completely mirror, provide some (almost) out-of-box configs
    创建非常完整的镜像, 既支持古老的网站(比如内网网站), 也支持巨型的现代化的网站
    提供几个(几乎)开箱即用的网站镜像配置文件
  2. Mirror ANY website, highly compatible
    非常高的兼容性和通用性, 可以镜像 任意 网站, 而不只是Google/Wiki/twitter/instagram, 而且功能都非常完整
    并且能很好地适应对现代化的、逻辑复杂、功能庞大的网站
    现在还在开发阶段, 虽然所有网站的绝大部分功能都可以开箱即用, 但是某些网站的某些功能仍然不完整, 正在不断改进
  3. (MIME-based) Local statistic file cache support (especially useful if we have low bandwidth or high latency)
    (基于MIME)本地静态文件缓存支持(当镜像服务器与被镜像服务器之间带宽很小或延迟很大时非常有用)
  4. CDN Support, hot statistic resource can serve by CDN, dramatically increase speed
    CDN支持. 让热门静态资源走CDN, 极大提高用户访问速度(特别是使用国内CDN, 而镜像服务器在国外时)
  5. Easy to config and deploy, highly automatic
    非常容易配置和部署, 镜像一个网站只需要添加它的域名即可
  6. Access control(IP, user-agent), visitor verification(question answer, or custom verification function)
    访问控制(IP, user-agent)与用户验证(回答问题, 也支持写自定义的验证函数)
  7. Automatically rewrite JSON/javascript/html/css, even dynamically generated url can ALSO be handled correctly
    自动重写JSON/javascript/html/css中链接, 甚至即使是动态生成的链接, 都能被正确处理
  8. Stream content support (audio/video)
    流媒体支持(视频/音频)
  9. Production ready.
    程序已经经受住了生产环境的考验
    使用的服务器均为 256M OpenVZ VPS
    Google:  
        单台服务器
        日6kPV, 峰值每小时740PV  
        峰值时段CPU占用小于10%  
    Youtube:  
        1台主服务器+8台视频服务器  
        日1wPV, 峰值每小时754PV  
        日发送流量178GB  
        高峰时段1080P流畅  
    

Issues Report

非常欢迎发issues, 发issues找我聊天都欢迎.
对于Apache(教程部署的即为Apache), 程序的日志在 /var/log/apache2/你自定义的日志文件名_error.log 中
(以下只是可选步骤)

Report zmirror Internal Error

当zmirror发生内部错误时(浏览器看到一个Internal Error页面), zmirror会把当前状态的快照保存到 zmirror安装目录/error_dump/ 中
可以使用pickle来读取其中的dump文件.
如果存在对应的dump文件, 请在issues中附上

Mirror A Website

本部分需要重写, 写的很乱, 也有点过时了 Mirror a website is very simple.
Just set the target_domain to it's domain, the external_domains to it's external domain and sub domains such as static resource domains (If it has)
save and run, the program will do the other works!
All detects and rewrites are completely AUTOMATICALLY
tips: you can find a website's external domains by using the developer tools of your browser, it will log all network traffics for you

Performance Enhance

Local Cache

Local file cache (along with 304 support) is implanted and enabled by default
If cache hits, you will see an x-zmirror-cache: FileHit in the response header.
Local cache will be deleted and cleaned once program exit.

CDN Support


Similar Projects

@zxq2233 youtube-php-mirroring
@greatfire website-mirror-by-proxy
@restran web-proxy
@isayme isayme/google
@zjuyxy google200
@cuber ngx_http_google_filter_module
@arnofeng ngx_google_deployment
@imlinhanchao ngx_proxy_wiki
@joymufeng play-google

from https://github.com/aploium/zmirror
------------------------------------------------------------

zmirror 一键部署脚本

使用zmirror快速部署镜像的脚本
如果无法部署成功, 可以尝试手动部署: 手动部署zmirror
或尝试由yumin9822提供的脚本

前置需求

  1. 一台墙外VPS, OpenVZ/Xen/KVM均可
  2. 操作系统:
    • 支持的操作系统:
      • Ubuntu 14.04/15.04(不支持HTTP2)/15.10/16.04+
      • Debian 8 (不支持HTTP/2)
      • 不支持 CentOS/RHEL/Windows/Fedora/Arch/... 对于这些系统, 可以使用由yumin9822提供的这个脚本
    • 推荐的操作系统:
      • Ubuntu 16.04 x86_64
    • 全新(刚安装完成)的操作系统. 如果系统中有其他东西, 可能会产生冲突
    • root权限
  3. 域名
    • 每个镜像要求一个三级域名(类似于g.zmirrordemo.com这样的, 有三部分, 两个点)
    • 域名已经在DNS记录中正确指向你的VPS
    提示
    如果你没有自己的域名, 请看FAQ-我没有自己的域名

运行方法

  • 我没有SSL证书 (如果不懂, 请使用这个)
    sudo apt-get -y update && sudo apt-get -y install python3 git
    git clone https://github.com/aploium/zmirror-onekey.git --depth=1
    cd zmirror-onekey
    sudo python3 deploy.py
    然后按照脚本给予的提示继续, 过程中会自动获取SSL证书
    如果有不懂的, 可参考下面的安装视频
    如果遇到bug, 请发issues提出
  • 我已有SSL证书
    如果已有证书, 希望使用自己提供的证书, 而不是通过 let's encrypt 获取
    请将上面代码中的第四行替换成下面的样子, 在运行期间会提示你输入证书路径的:
    sudo python3 deploy.py --i-have-cert
    警告
    不支持加密的私钥, 如果私钥有密码加密, 请先解密

安装过程视频

请点击下面的图片打开
"视频"中的文字可以被选中和复制
Installation demo of zmirror-onekey

特性

  • 支持一次部署多个镜像, 支持同VPS多镜像
  • 自动安装 let's encrypt 并申请证书, 启用HTTPS
  • 自动添加 let's encrypt 的定期renew脚本到crontab
  • 启用HTTP/2 ps:Debian8和Ubuntu15.04不支持HTTP/2
  • 启用HSTS

FAQ

  1. 有没有部署完成的Demo?

    当然有, 请戳 zmirror-demo
  2. 我没有自己的域名

    有一些提供免费(也没有注册门槛)域名的注册商
    比如最有名的 .tk 域名
    可以快速注册免费的域名
    注意
    请不要使用 .cf 和 .ga 域名, letsencrypt对它们的支持非常差, 经常出现无法下发证书的问题
    除非不得已, 在使用免费域名时, 请使用老牌的 .tk 域名
  3. 安装完成后各个程序的文件夹在哪?

    • zmirror
      安装在 /var/www/镜像名 文件夹下
      镜像名为每个镜像的名字, 比如YoutubePC就是 /var/www/youtubePC
    • let's encrypt
      本体在: /etc/certbot/
      申请到的证书位置, 请看 certbot文档-where-are-my-certificates
    • Apache
      Apache的配置文件在/etc/apache2/
      其中各个站点的配置文件在/etc/apache2/sites-enabled/
      Apache日志文件在/var/log/apache2/镜像名_后缀.log
      后缀为 _error 的日志文件中, 同时包含了stdout的输出(无论是否是错误), 对debug会有帮助
  4. 为什么安装的是Apache, 而不是Nginx, 我可以选择吗?

    因为Apache的wsgi对python更友好
    而且Nginx没有Visual Host功能
    在性能上, 由于性能瓶颈是zmirror本身, 所以Apache和Nginx之间的性能差距可以被忽略
    目前一键脚本只能安装Apache, 不支持Nginx, 也没有支持Nginx的计划, 如果需要Nginx, 请手动部署
    手动部署可以参考 zmirror wiki
    当然, 如果你能写一份Nginx部署教程, 我会很感谢的~ :)
  5. 安装的Apache版本?

    在Ubuntu中, 使用的是 PPA:ondrej/apache2 理论上应该是最新版, 或者接近最新版(2.4.23+)
    在Debian8中, 使用系统的 apt-get 安装, 版本比较旧, 所以Debian不支持HTTP/2
  6. Let's encrypt 证书自动更新?

    安装脚本会自动创建定期更新证书的脚本, 脚本位置为 /etc/cron.weekly/zmirror-letsencrypt-renew.sh
  7. 证书有效期为什么只有90天?

    主要是因为Let's encrypt认为, 证书的申请和部署可以自动化时, 90天足够了.
    具体可以看这个官方说明(可能需要自备梯子)
    本安装脚本会在linux定时任务(crontab)中加入自动续期的脚本, 不用担心证书过期
    即使自动续期脚本万一失效了, let's encrypt也会在快要过期时邮件通知你
  8. 其他高级功能, 比如说CDN, 在哪?

    这个脚本只提供最基础的部署, 高级功能需要手动配置
    请看config_default.pycustom_func.sample.py中的说明
    如果想用CDN, 可以看这个教程使用七牛作为zmirror镜像CDN
    警告
    如果你想要修改config_default.py中的某项设置, 请不要直接修改
    而应该将它复制到config.py中, 然后修改config.py里的设置
    config.py中的设置会覆盖掉config_default.py中的同名设置
    除非你是开发者, 否则无论如何都不应该修改config_default.py
  9. 网速太慢?

    如果你的VPS提供商允许的话, 可以试试看net-speeder
    或者换一个网速快的VPS, Demo站使用的VPS是Ramnode
    服务器地点是LA(Los Angeles), 速度相当快.
    ps: 如果你也想试试看的话, 请点击这个链接进入, 这里有我的推广小尾巴, 你买了的话我会有一丢丢(好像是10%)分成
    ramnode允许使用net-speeder
  10. 证书获取失败

脚本使用[Let's encrypt(certbot)](https://letsencrypt.org/)来获取证书  
  
certbot 会在本地 Listen 80 或者 443 端口, 然后由远程授权服务器根据**域名的[A记录](https://support.dnspod.cn/Kb/showarticle/tsid/30/)**来**访问本机**  
当远程服务器成功连接到本机的certbot客户端后, 就会颁发证书.  
详细流程请看官方文档[How It Works](https://letsencrypt.org/how-it-works/)  

证书获取失败最有可能的原因是域名记录设置后[尚未来得及生效](https://support.dnspod.cn/Kb/showarticle/tsid/53/), 域名DNS记录的生效通常需要数分钟以上, 最长可达*72小时*  
对于这种情况, 除了等待以外是没有什么办法的.  
本脚本在默认的5次尝试失败后, 会提示是否一直尝试下去, 如果你确认DNS记录已经正常设置, 请在提示  
`max retries exceed, do you want to continue retry infinity?(Y/n)`  
时, 选择Y, 一般数分钟内就能成功.  

如果不能确定是否正常设置, 可以访问 https://www.whatsmydns.net/ , 这个网站可以在全球范围内查询A记录  
如果查询出的A记录与你的IP相同, 就表示设置成功了, 此时只需要让脚本自行尝试即可  
如果此时仍然多次尝试失败, 请看下面的`手动运行lets encrypt获取证书`部分  

> **手动运行lets encrypt获取证书**  
> 如果能确认DNS记录已经设置正常, 但是仍然无法获取证书, 请尝试手动运行letsencrypt获取证书:
>   
> ```bash
> sudo service apache2 stop
> sudo /etc/certbot/certbot-auto certonly --standalone -d "你的域名1"
> sudo /etc/certbot/certbot-auto certonly --standalone -d "你的域名2"
> sudo service apache2 start
> ```
>   
> 或者(如果上面的仍然失败)  
> ```bash
> sudo apt-get install letsencrypt
> sudo service apache2 stop
> sudo letsencrypt certonly --standalone -d "你的域名1"
> sudo letsencrypt certonly --standalone -d "你的域名2"
> sudo service apache2 start
> ```
>
> 并在手动获取证书成功后再次运行本脚本  
  1. 更新zmirror

    请运行以下代码(假设zmirror-onekey是本脚本文件夹):
    cd zmirror-onekey
    git pull
    sudo python3 deploy.py --upgrade-only
    注意: 更新zmirror以后会自动重启Apache
 from https://github.com/aploium/zmirror-onekey
-----------

手动安装zmirror

需求

1、一台墙外VPS,虚拟化技术 OpenVZ/Xen/KVM 均可。
2、操作系统:
  • 支持的操作系统:
    • Ubuntu 14.04/15.04(不支持HTTP2)/15.10/16.04+
    • Debian 8 (不支持HTTP/2)
    • 不支持 CentOS/RHEL/Windows/Fedora/Arch/…
  • 推荐的操作系统:
    • Ubuntu 16.04 x86_64
  • 全新(刚安装完成)的操作系统。如果系统中有其他东西,可能会产生冲突
  • root权限
3、域名
  • 每个镜像要求一个三级域名(类似于g.zmirrordemo.com这样的,有三部分,两个点)
  • 域名已经正常解析到VPS IP

安装步骤

没有SSL证书 (如果不懂, 请使用这个)

以下教程中,示例域名为: xxx.xxx ,示例邮箱为: XXXXXX@gmail.com ,示例VPS IP为: 233.233.233.233 ,你们不要傻傻的跟着填。
注意:安装前请先解析好域名,否则SSL证书可能申请失败!
  1. sudo apt-get -y update && sudo apt-get -y install python3 git
  2. git clone https://github.com/aploium/zmirror-onekey.git --depth=1
  3. cd zmirror-onekey
  4. sudo python3 deploy.py
运行后会自动开始安装各个依赖,可能需要等几分钟,等安装完毕后会提示你添加镜像:
  1. [20:58:25] [INFO] executing: service apache2 start
  2. [20:58:27] [INFO] Load last installation's settings successfully
  3. [20:58:27] [INFO] ----------------------
  4. Please select mirror you want to deploy?
  5. select one mirror a time, you could select zero or more mirror(s)
  6.  
  7. 1. Google (include scholar, image, zh_wikipedia)
  8. 2. twitter (PC ONLY)
  9. 3. twitter (Mobile ONLY)
  10. 4. youtube (PC ONLY)
  11. 5. youtube (Mobile ONLY)
  12. 6. instagram
  13. 0. Go to next steps. (OK, I have selected all mirror(s) I want to deploy)
  14.  
  15. input 0-6:
这是提示你添加镜像,Twitter 和 Youtube区分PC和手机的,而且域名也不能相同。
你输入对应的数字,比如 1 ,Google,然后会提示你输入Google镜像的域名。
  1. Please input *your* domain for this mirror (google):
注意:在这整个步骤中,输入的任何文本都无法 退车键 删除,所以不要打错字,否则就必须重来了。
输入域名后回车,会检测你的域名解析是否正确,但是好像脚本有问题,会识别本地IP为 127.0.0.1 ,所以这一步直接输入,然后回车。
注意:安装前请先解析好域名,否则SSL证书可能申请失败!
  1. [20:59:05] [WARNING] Sorry, your domain(google.xxx.xxx)'s ip does not equals to this machine's ip.
  2. domain's ip is: 233.233.233.233
  3. this machine's ip is: 127.0.0.1
  4. Continue anyway? (y/N):
回车后又会回到上面添加镜像的提示,你可以继续添加镜像或者输入 0 来继续下一步,回车后会提醒你输入一个邮箱地址(需要真实)这个是申请SSL证书用的。
  1. Please input your email (because letsencrypt requires an email for certification)
回车后就会限速你输入的邮箱,同时提示你是否对镜像设置密码,不使用输入 N 回车。
  1. [21:00:04] [INFO] Your email: XXXXXX@gmail.com
  2.  
  3. [21:00:04] [INFO] zmirror can provide simple verification via password
  4. just as you may have seen in zmirror's demo sites (however, demo sites does not require correct answer)
  5. Do you want to protect your mirror by password? (y/N):
回车后会再次显示你的 邮箱和添加的镜像域名 ,确认无误后输入 Y 回车。
  1. [21:00:18] [INFO] ----------------------
  2. [21:00:18] [INFO] Now, we are going to install, please check your settings here:
  3. Email: XXXXXX@gmail.com
  4.  
  5. Mirror: google Domain: google.xxx.xxx
  6. Mirror: youtubePC Domain: youtube.xxx.xxx
  7. Are these settings correct (Y/n)?
然后就会开始自动申请SSL并且配置文件了,等一切配置完毕之后,就会提示下面的内容。
如果没有提示出错,那么就一切正常安装完毕了。
这时候你就可以使用 https://google.xxx.xxx/ 来访问Google镜像,使用 https://youtube.xxx.xxx/ 来访问PC的Youtube镜像了。

已有SSL证书

如果已有证书,希望使用自己提供的证书,而不是通过 let’s encrypt 获取。
请将上面代码中的第四行替换成下面的样子,在运行期间会提示你输入证书路径的:
  1. sudo apt-get -y update && sudo apt-get -y install python3 git
  2. git clone https://github.com/aploium/zmirror-onekey.git --depth=1
  3. cd zmirror-onekey
  4. sudo python3 deploy.py --i-have-cert
警告:不支持加密的私钥,如果私钥有密码加密,请先解密。

特性

  1. 支持一次部署多个镜像, 支持同VPS多镜像
  2. 自动安装 let’s encrypt 并申请证书, 启用HTTPS
  3. 自动添加 let’s encrypt 的定期renew脚本到crontab
  4. 启用HTTP/2 ps:Debian8和Ubuntu15.04不支持HTTP/2
  5. 启用HSTS

FAQ

  • 安装完成后各个程序的文件夹在哪?
zmirror:
安装在 /var/www/镜像名 文件夹下
镜像名为每个镜像的名字, 比如YoutubePC就是 /var/www/youtubePC
let’s encrypt:
本体在: /etc/certbot/
申请到的证书位置, 请看 certbot文档-where-are-my-certificates
Apache:
Apache的配置文件在 /etc/apache2/
其中各个站点的配置文件在 /etc/apache2/sites-enabled/
Apache日志文件在 /var/log/apache2/镜像名_后缀.log
后缀为 _error 的日志文件中, 同时包含了stdout的输出(无论是否是错误), 对debug会有帮助
  • 为什么安装的是Apache, 而不是Nginx, 我可以选择吗?
因为Apache的wsgi对python更友好,而且Nginx没有Visual Host功能。
在性能上,由于性能瓶颈是zmirror本身,所以Apache和Nginx之间的性能差距可以被忽略
目前一键脚本只能安装Apache,不支持Nginx, 也没有支持Nginx的计划,如果需要Nginx,请手动部署。
手动部署可以参考 zmirror wiki
  • 安装的Apache版本?
在Ubuntu中,使用的是 PPA:ondrej/apache2 理论上应该是最新版,或者接近最新版(2.4.23+)
在Debian8中,使用系统的 apt-get 安装,版本比较旧,所以Debian不支持HTTP/2
  • Let’s encrypt 证书自动更新?
安装脚本会自动创建定期更新证书的脚本,脚本位置为 /etc/cron.weekly/zmirror-letsencrypt-renew.sh
  • 证书有效期为什么只有90天?
主要是因为Let’s encrypt认为,证书的申请和部署可以自动化时,90天足够了。
具体可以看这个官方说明(可能需要自备梯子)。
本安装脚本会在linux定时任务(crontab)中加入自动续期的脚本,不用担心证书过期。
即使自动续期脚本万一失效了,let’s encrypt也会在快要过期时邮件通知你。
  • 其他高级功能, 比如说CDN, 在哪?
这个脚本只提供最基础的部署,高级功能需要手动配置。
请看 config_default.py custom_func.sample.py 中的说明.

警告:
如果你想要修改 config_default.py 中的某项设置,请不要直接修改。
而应该将它复制到 config.py 中,然后修改 config.py 里的设置。
config.py 中的设置会覆盖掉 config_default.py 中的同名设置。
除非你是开发者,否则无论如何都不应该修改 config_default.py
  • 网速太慢?
可以尝试使用一些单边的优化加速方法.
或者换一个网速快的VPS,比如:Vultr,注册后送20美元,5美元用5个月。
Vultr是KVM,支持锐速。
  • 证书获取失败
脚本使用Let’s encrypt(certbot)来获取证书。
certbot 会在本地 Listen 80 或者 443 端口,然后由远程授权服务器根据域名的A记录来访问本机
当远程服务器成功连接到本机的certbot客户端后, 就会颁发证书。
详细流程请看官方文档How It Works
证书获取失败最有可能的原因是域名记录设置后尚未来得及生效,域名DNS记录的生效通常需要数分钟以上,最长可达72小时。
对于这种情况, 除了等待以外是没有什么办法的。
本脚本在默认的5次尝试失败后,会提示是否一直尝试下去,如果你确认DNS记录已经正常设置,请在提示
  1. max retries exceed, do you want to continue retry infinity?(Y/n)
时,选择,一般数分钟内就能成功。
如果不能确定是否正常设置,可以访问 https://www.whatsmydns.net/,这个网站可以在全球范围内查询A记录。
如果查询出的A记录与你的IP相同,就表示设置成功了,此时只需要让脚本自行尝试即可。
如果此时仍然多次尝试失败,请看下面的手动运行lets encrypt获取证书部分。
手动运行lets encrypt获取证书
如果能确认DNS记录已经设置正常, 但是仍然无法获取证书, 请尝试手动运行letsencrypt获取证书:
  1. sudo service apache2 stop
  2. sudo /etc/certbot/certbot-auto certonly --standalone -d "你的域名1"
  3. sudo /etc/certbot/certbot-auto certonly --standalone -d "你的域名2"
  4. sudo service apache2 start
或者(如果上面的仍然失败)
  1. sudo apt-get install letsencrypt
  2. sudo service apache2 stop
  3. sudo letsencrypt certonly --standalone -d "你的域名1"
  4. sudo letsencrypt certonly --standalone -d "你的域名2"
  5. sudo service apache2 start
并在手动获取证书成功后再次运行本脚本

更新zmirror

请运行以下代码(假设zmirror-onekey是本脚本文件夹):
  1. cd zmirror-onekey
  2. git pull
  3. sudo python3 deploy.py --upgrade-only
注意: 更新zmirror以后会自动重启Apache
本教程转载自Github:https://github.com/aploium/zmirror-onekey