Coder Social home page Coder Social logo

zmirror's Introduction

zmirror

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自带镜像配置文件

请在遵守当地相关法律法规的前提下使用本项目
本人拒绝为任何商业或非法目的提供任何技术支持
本项目仅为科研人员更方便地查询知识而创建, 请勿大范围传播

若想看代码, 请看 v0.30-dev 这个分支
请不要大量使用...demo服务器马上要爆炸了- -|

Demo

Screenshot

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

一键部署脚本

https://github.com/aploium/zmirror-onekey
一键部署脚本仍然不稳定, 如果怎么弄都失败, 请看手动教程

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镜像

在Nginx下部署, 请看这里(感谢@phuslu)

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)
    流媒体支持(视频/音频)

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

please see 使用七牛作为zmirror镜像的CDN


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

zmirror's People

Contributors

aploium avatar gaocegege avatar zjuchenyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zmirror's Issues

请问安装apache时这个命令找不到是怎么回事?

作者你好,我在一台新的VPS上装新版apache,可是不知道它的系统是怎么回事,安装的时候没有想象中的那么顺利。
sudo a2enmod rewrite mime include headers filter expires deflate autoindex setenvif ssl http2
sudo: a2enmod: command not found
root@ubuntu:~#

系统是Ubuntu-14.04.1-LTS-64bit。

我想手动部署zmirror,但是apache启动不了。

作者你好,我按照《部署支持HTTPS和HTTP2.0的镜像》一步一步安装一个google镜像,但是用的是自己签发的证书。
这个证书有两个文件,一个key文件,一个crt文件。我把配置文件全部弄好了,执行sudo service apache2 restart却显示如下:
root@UnawareOnly-VM:~# sudo service apache2 restart

  • Restarting Apache httpd web server apache2 Action 'start' failed.
    The Apache error log may have more information.

我就看了看错误日志,日志如下:
[Fri Sep 30 08:40:06.965851 2016] [ssl:emerg] [pid 6880:tid 3074701952] AH02561: Failed to configure certificate g.yandere.cf:443:0, check /root/zmirror/1.key
[Fri Sep 30 08:40:06.965935 2016] [ssl:emerg] [pid 6880:tid 3074701952] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: CERTIFICATE) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Fri Sep 30 08:40:06.965957 2016] [ssl:emerg] [pid 6880:tid 3074701952] SSL Library Error: error:140AD009:SSL routines:SSL_CTX_use_certificate_file:PEM lib
[Fri Sep 30 08:44:31.538445 2016] [ssl:emerg] [pid 6923:tid 3074718336] AH02561: Failed to configure certificate g.yandere.cf:443:0, check /root/zmirror/1.key
[Fri Sep 30 08:44:31.538644 2016] [ssl:emerg] [pid 6923:tid 3074718336] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: CERTIFICATE) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Fri Sep 30 08:44:31.538665 2016] [ssl:emerg] [pid 6923:tid 3074718336] SSL Library Error: error:140AD009:SSL routines:SSL_CTX_use_certificate_file:PEM lib
[Fri Sep 30 08:46:59.981155 2016] [ssl:emerg] [pid 6954:tid 3074042496] AH02561: Failed to configure certificate g.yandere.cf:443:0, check /root/zmirror/1.key
[Fri Sep 30 08:46:59.981240 2016] [ssl:emerg] [pid 6954:tid 3074042496] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: CERTIFICATE) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Fri Sep 30 08:46:59.981261 2016] [ssl:emerg] [pid 6954:tid 3074042496] SSL Library Error: error:140AD009:SSL routines:SSL_CTX_use_certificate_file:PEM lib

我百度了一下都没有找到解决方法,还有我用zmirror-onekey用同样的证书却可以安装完毕,这是怎么回事?

external_domains 问题?

google镜像中external_domains 添加www.toptenreviews.com & www.economist.com,总是出现zmirror internal error.(openshift平台 python 3.3)

Detail
Attrib Value
cache_control None
cacheable False
client_header {'connection': 'Keep-Alive', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'x-forwarded-for': '', 'x-forwarded-proto': 'https', 'x-client-ip': '', 'accept-language': 'en-US,en;q=0.8,zh-CN;q=0.5,zh;q=0.3', 'x-forwarded-ssl-client-cert': '', 'x-forwarded-port': '443', 'x-forwarded-host': 'www.google.com', 'referer': 'https://', 'x-forwarded-server': 'www.google.com', 'x-request-start': 't=1480296314766230', 'accept-encoding': 'gzip, deflate'}
content_type None
dump <bound method ZmirrorThreadLocal.dump of <zmirror.threadlocal.ZmirrorThreadLocal object at 0x7fe7a19fa390>>
extra_cookies {}
extra_resp_headers {}
init <bound method ZmirrorThreadLocal.init of <zmirror.threadlocal.ZmirrorThreadLocal object at 0x7fe7a19fa390>>
is_external_domain True
is_https True
method GET
mime None
remote_domain www.toptenreviews.com
remote_path /
remote_path_query /
remote_response None
remote_url https://www.toptenreviews.com/
request_data
request_data_encoded b''
request_data_encoding utf-8
set_cookies <bound method ZmirrorThreadLocal.set_cookies of <zmirror.threadlocal.ZmirrorThreadLocal object at 0x7fe7a19fa390>>
set_extra_resp_header <bound method ZmirrorThreadLocal.set_extra_resp_header of <zmirror.threadlocal.ZmirrorThreadLocal object at 0x7fe7a19fa390>>
streamed_our_response False
temporary_domain_alias []
time {'start_time': 1.11560118, 'req_start_time': 1480296314.776441}
url_no_scheme www.toptenreviews.com/
Additional Information

Unknown Error

Traceback

Traceback (most recent call last):
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 594, in urlopen
chunked=chunked)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 350, in _make_request
self._validate_conn(conn)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 835, in _validate_conn
conn.connect()
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/packages/urllib3/connection.py", line 339, in connect
_match_hostname(cert, self.assert_hostname or hostname)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/packages/urllib3/connection.py", line 349, in _match_hostname
match_hostname(cert, asserted_hostname)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py", line 150, in match_hostname
% (hostname, ', '.join(map(repr, dnsnames))))
requests.packages.urllib3.packages.ssl_match_hostname._implementation.CertificateError: hostname 'www.toptenreviews.com' doesn't match either of 'a248.e.akamai.net', '.akamaized.net', '.akamaihd-staging.net', '.akamaihd.net', '.akamaized-staging.net'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/packages/urllib3/connectionpool.py", line 624, in urlopen
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: hostname 'www.toptenreviews.com' doesn't match either of 'a248.e.akamai.net', '.akamaized.net', '.akamaihd-staging.net', '.akamaihd.net', '.akamaized-staging.net'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 2405, in zmirror_enter
resp = main_function(input_path=input_path)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 2481, in main_function
request_remote_site()
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 2012, in request_remote_site
data=parse.request_data_encoded,
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 1773, in send_request
verify=not developer_do_not_verify_ssl,
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: hostname 'www.toptenreviews.com' doesn't match either of 'a248.e.akamai.net', '.akamaized.net', '.akamaihd-staging.net', '.akamaihd.net', '.akamaized-staging.net'

vps-bandwagonhost部署的谷歌不定期报错重启apache2会恢复

我在另一个vps的就不会,已经更新到最新版,但是还是不定期的出现下面的额错误,重启apache2后又会恢复正常。

apache2日志如下:

[Mon Nov 07 22:19:37.455355 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 109.190.102.122:8740]     response = self.make_response(rv)
[Mon Nov 07 22:19:37.455361 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 109.190.102.122:8740]   File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1731, in make_response
[Mon Nov 07 22:19:37.455367 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 109.190.102.122:8740]     raise ValueError('View function did not return a response')
[Mon Nov 07 22:19:37.455390 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 109.190.102.122:8740] ValueError: View function did not return a response
[Mon Nov 07 22:19:37.455420 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 109.190.102.122:8740]
[Mon Nov 07 22:25:25.637749 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996] [2016-11-07 22:25:25,637] ERROR in app: Exception on /ip_ban_verify_page [HEAD]
[Mon Nov 07 22:25:25.637789 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996] Traceback (most recent call last):
[Mon Nov 07 22:25:25.637795 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996]   File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1988, in wsgi_app
[Mon Nov 07 22:25:25.637799 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996]     response = self.full_dispatch_request()
[Mon Nov 07 22:25:25.637804 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996]   File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1642, in full_dispatch_
request
[Mon Nov 07 22:25:25.637808 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996]     response = self.make_response(rv)
[Mon Nov 07 22:25:25.637812 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996]   File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1731, in make_response
[Mon Nov 07 22:25:25.637817 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996]     raise ValueError('View function did not return a response')
[Mon Nov 07 22:25:25.637823 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996] ValueError: View function did not return a response
[Mon Nov 07 22:25:25.637843 2016] [wsgi:error] [pid 17190:tid 140445830973184] [remote 139.129.217.191:8996]
[Mon Nov 07 22:29:41.957462 2016] [wsgi:error] [pid 17190:tid 140445663115008] [22:29:41] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Mon Nov 07 22:29:41.957529 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Mon Nov 07 22:44:42.058541 2016] [wsgi:error] [pid 17190:tid 140445663115008] [22:44:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Mon Nov 07 22:44:42.058601 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Mon Nov 07 22:59:42.158404 2016] [wsgi:error] [pid 17190:tid 140445663115008] [22:59:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Mon Nov 07 22:59:42.158482 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Mon Nov 07 23:14:42.258899 2016] [wsgi:error] [pid 17190:tid 140445663115008] [23:14:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Mon Nov 07 23:14:42.258965 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Mon Nov 07 23:29:42.359301 2016] [wsgi:error] [pid 17190:tid 140445663115008] [23:29:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Mon Nov 07 23:29:42.359357 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Mon Nov 07 23:44:42.459341 2016] [wsgi:error] [pid 17190:tid 140445663115008] [23:44:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Mon Nov 07 23:44:42.459413 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Mon Nov 07 23:59:42.559557 2016] [wsgi:error] [pid 17190:tid 140445663115008] [23:59:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Mon Nov 07 23:59:42.559633 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Tue Nov 08 00:14:42.659405 2016] [wsgi:error] [pid 17190:tid 140445663115008] [00:14:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Tue Nov 08 00:14:42.659461 2016] [wsgi:error] [pid 17190:tid 140445663115008]
[Tue Nov 08 00:29:42.759402 2016] [wsgi:error] [pid 17190:tid 140445663115008] [00:29:42] [INFO] CronTask: cache_clean_soft Target: <function cache_clean at 0x7fbc0ea0bb70>
[Tue Nov 08 00:29:42.759487 2016] [wsgi:error] [pid 17190:tid 140445663115008]

有关正则替换的一些问题

你好,我正在看你的代码,对网址替换有个感兴趣的地方

# 前缀, 必须有  'action='(表单) 'href='(链接) 'src=' 'url('(css) '@import'(css) '":'(js/json, "key":"value")

这里看到你对js的中的网址替换,就只有一种情况的替换,实际的操作中,会不会有更复杂的情况的呢?

不管是什么镜像,图片有时在浏览器上会变成裂图

不管是什么镜像,图片有时在浏览器上会变成裂图,这个在Youtube上有,在Facebook、Twitter上都有。其实我对着那些裂图右击,选择“在新标签页中打开图片”是可以打开出一张图片的。
P.S:我是在128M内存的VPS上遇到的。发生裂图时内存已经快要占满了,想问问是不是内存不足的原因,如果是,有没有办法能解决这个bug?
截图:
https://ww3.sinaimg.cn/large/0063W5ctgw1fan4ezdq3wj31hc0qgtlx.jpg

直接运行时Port80被占用

root@a:/zmirror# python3 wsgi.py
[16:36:07] [INFO] zmirror version: 0.23.1-dev from Aploium [email protected]
[16:36:07] [INFO] Github: https://github.com/Aploium/zmirror
[16:36:07] [INFO] config file found
[16:36:07] [INFO] Local file cache enabled
Traceback (most recent call last):
File "wsgi.py", line 24, in
host='0.0.0.0', # \u9ed8\u8ba4\u53ea\u5141\u8bb8\u672c\u673a\u8bbf\u95ee, \u5982\u679c\u4f60\u5e0c\u671b\u8ba9\u5916\u7f51\u8bbf\u95ee, \u8bf7\u53bb\u6389\u672c\u884c\u7684\u6ce8\u91ca
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 843, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python3.4/dist-packages/werkzeug/serving.py", line 694, in run_simple
inner()
File "/usr/local/lib/python3.4/dist-packages/werkzeug/serving.py", line 656, in inner
fd=fd)
File "/usr/local/lib/python3.4/dist-packages/werkzeug/serving.py", line 544, in make_server
passthrough_errors, ssl_context, fd=fd)
File "/usr/local/lib/python3.4/dist-packages/werkzeug/serving.py", line 464, in init
HTTPServer.init(self, (host, int(port)), handler)
File "/usr/lib/python3.4/socketserver.py", line 429, in init
self.server_bind()
File "/usr/lib/python3.4/http/server.py", line 133, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.4/socketserver.py", line 440, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
root@a:
/zmirror#

尝试在 nginx 环境下部署了 zmirror.

操作系统: Ubuntu 16.04 LTS
前置要求: 已经安装了 nginx 并配置了域名和 SSL 证书。

安装的命令:

# 安装系统必须的 python 环境
sudo apt install python-virtaulenv python-dev python-pip
# 克隆 zmirror 到 /opt 目录
git clone https://github.com/aploium/zmirror /opt/zmirror
cd /opt/zmirror
# 创建 virtualenv
virtualenv -p python3 venv
# 安装 gunicron
./venv/bin/pip install -i https://pypi.douban.com/simple gunicorn gevent
# 安装 zmirror 自身依赖
./venv/bin/pip install -i https://pypi.douban.com/simple -r requirements.txt
# 编辑 config.py
cp more_configs/config_google_and_zhwikipedia.py config.py
echo -e  '\nverbose_level = 1' >config.py
sed -ir 's/my_host_name =.+/my_host_name = "你的域名"/g' config.py
# 启动 zmirror 服务器
./venv/bin/gunicorn --daemon --capture-output --log-file zmirror.log --access-logfile zmirror-access.log --bind 127.0.0.1:8001 --workers 2 --worker-connections 100 wsgi:application

好了,这样 zmirror 已经在本地 8001 HTTP 端口跑起来了,接下里就可以编辑 nginx.conf 转发给它了。这个就不再赘述。

v0.30.0: 计划进行一次大的向下不兼容的重构

重构内容

  • 将config的解析从 zmirror/zmirror.py 中独立出来
  • config 中的项不会在出现在 zmirror.py 的全局空间, 而是在 cfg.设置项
  • tests 目录移动到 zmirror/tests
  • 将parse变量从 zmirror.py 移动到 threadlocal.py 以便其他代码从中引用
  • 把正则部分移动到regex模块 (部分完成)
  • 将某些依赖于parse变量的函数从 zmirror.py 移动到单独的文件
  • 拆分现有的一些较长的函数
  • 尝试把两个 regex assemble 函数整合在一起
  • 添加一个升级脚本upgrade.py, 以便未来在遇到向下不兼容的改动后进行平滑迁移
  • 改进代码质量以提升code climate分数
  • 待补充
  • 重命名human_ip_verificationsimple_verify

不兼容性

  1. 所有类似于 import config.py 的导入配置的方式可能会产生问题
  2. from zmirror.zmirror import [config选项] 会失效
  3. 总的来说, 内置配置文件中的youtube twitter会向前不兼容, 在0.30之前部署的youtube和twitter镜像无法通过常规的 git pull 来升级到0.30 其余镜像(如google)不受影响

一键包错误提示

  • Restarting Apache httpd web server apache2 AH00557: apache2: apr_sockaddr_info_get() failed for localhost.localdomain
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
    安装一键包的时候出现的提示,应该怎么解决?

我的按照手动出现如下提示

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 2604:a880:1:20::e1e:d001(我的vps的)IPV6地址. Set the 'ServerName' directive globally to suppress this message。是因为vps有IPV6地址的原因还是自己的域名解析的问题?

Youtube有部分视频不能加载

今天刚发现的bug,Youtube有一些视频始终加载不出来,但是在原版的Youtube是可以加载出来的。
我刚开始以为是自己的问题,但是我在zmirror youtube demo上也发现有这个问题。

不能加载的视频:https://ytb-pc.zmirrordemo.com/watch?v=YNh3IyGMfQI

我自己遇到问题时的截图:
https://ww3.sinaimg.cn/large/0063W5ctgw1fan3todcbwj30xe0pxgs4.jpg
https://ww4.sinaimg.cn/large/0063W5ctgw1fan3vjxrsaj30xe0px7cc.jpg

external_domains 内网站只能设置HTTPS?不支持只有HTTP的网站?

Traceback (most recent call last):
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 2405, in zmirror_enter
resp = main_function(input_path=input_path)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 2481, in main_function
request_remote_site()
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 2012, in request_remote_site
data=parse.request_data_encoded,
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/app-root/runtime/repo/zmirror/zmirror.py", line 1773, in send_request
verify=not developer_do_not_verify_ssl,
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/var/lib/openshift/5833bfe789f5cfe6e200014b/python/virtenv/venv/lib/python3.3/site-packages/requests/adapters.py", line 487, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='51.ruyo.net', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe7a14b0dd0>: Failed to establish a new connection: [Errno 111] Connection refused',))

Instagram 无限重定向

很久没有登陆过Instagram,会出现“你的帐户出现异常活动。我们将给你发送验证码,以验证账户”。选择邮件验证后通过后会重定到登录页面,如此循环,其他google 、youtube暂时没有发现bug。

qiniu好像没起作用

我开了三个域名,然后是拿代instagram的域名给的qiniu
但是并没有转到qiniu,一切都按教程脚本来

fastcache在windows下安装失败

想弄个youtube镜像,然后在windows搭建,报错custom_text_rewriter_enable = True这句,显示缺少fastcache模块,请用pip3 install fastcache,这样安装的话又出现了could not find a version that satisfies the requirement fastchaache(似乎没有适合的版本??)禁用custom_text_rewriter_enable = True这句后,可以打开网页了,但是视频无法加载

出现错误提示

Detail: Failed to connect to 104.28.18.72:443 for TLS-SNI-01
challenge

To fix these errors, please make sure that your domain name was
entered correctly and the DNS A record(s) for that domain
contain(s) the right IP address. Additionally, please check that
you have an up-to-date TLS configuration that allows the server to
communicate with the Certbot client.

  • Your account credentials have been saved in your Certbot
    configuration directory at /etc/letsencrypt. You should make a
    secure backup of this folder now. This configuration directory will
    also contain certificates and private keys obtained by Certbot so
    making regular backups of this folder is ideal.

a记录没有问题。。已经尝试了两个域名了。

请问执行sudo service apache2 restart不成功是怎么回事?

root@ubuntu:~# sudo service apache2 restart

  • Restarting Apache httpd web server apache2 [fail]
  • The apache2 configtest failed.
    Output of config test was:
    AH00526: Syntax error on line 19 of /etc/apache2/conf-enabled/google.conf:
    Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a module not included in the server configuration
    Action 'configtest' failed.
    The Apache error log may have more information.
    root@ubuntu:~#

第19行是
WSGIDaemonProcess zmirror_google user=www-data group=www-data threads=16
我没有改过这个,我只是改了路径(在/var/www/文件夹里)和域名还有证书路径(在/etc/apache/文件夹里)。

海盗湾有一个bug

由于网站自动动态添加域名,导致点击 下载torrent时会在magnet之前默认添加域名,使打开的链接变成了*.xxxx.cn/magnet:?xt=xxxxxxxxxxx 而无法下载种子,希望修复或者提供解决办法,谢谢

请问能解决访问镜像时经常500的问题么?

我今天刚在一台128MB内存的VPS上装了zmirror的Facebook镜像,同时还装了google、twitter、twittermobile、youtube、youtubemobile、instagram的镜像和net-speeder,然而有时候访问facebook镜像的时候经常显示下面这些东西。

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.23 (Ubuntu) Server at (这里是我的镜像域名)Port 443

我记得以前我在一台512MB内存的VPS上装了这7个镜像,用久了也会500,有没有办法解决呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.