Thousands of websites are blocked in China. One approach to tackle this is to create mirror websites. The main problem of mirror websites is finding them. This project remedies that problem partially by automatically redirecting users to a mirror website if the original website cannot be accessed (presumably because it has been blocked). Additionally if the mirror website itself is blocked, it can in turn redirect to another mirror website. This works if:
- The user has visited the website succesfully in the past at least once.
- The user is using a compatible web browser (see below).
Two editions
- Basic Edition: https://github.com/greatfire/redirect-when-blocked/tree/master/basic
- Full Edition: https://github.com/greatfire/redirect-when-blocked/tree/master/full
Basic Edition | Full Edition | |
---|---|---|
Server requirements | None | PHP |
Accessibility and SEO implications | None | Major |
Speed | Slow / unpredictable | Fast |
Inspiration
This project owes its existence entirely to https://github.com/willscott/activist/. We have copied the approach to utilize the HTM5L Application Cache to rescue users who cannot access the website. This project is different from activist.js in the following ways:- It does not cache the website itself. We are using the application cache to address censorship, and we don't assume that the website itself should be cached. Caching the website itself involves issues like having to manually reload resources when content has been updated. We want the impact on the website to be minimal.
- We are focusing on redirecting users to alternative URLs when the original URL has been blocked, not keeping the original alive.
- We are creating this specifically to combat the Great Firewall of China, though this approach could also be used to tackle web filtering elsewhere.
How to test that it works
- Implement this project on a website (or use one of the demo URLs).
- Load the website in a browser.
- Alter your connection so that you cannot access the website anymore. For example, you can modify your hosts file to point the hostname at a non-responsive IP address (simulating DNS poisoning). Or if the hostname is actually blocked by the GFW, just access the website from inside the GFW.
- After some delay, your browser should redirect you to the backup URL that you configured.
If you need a mirror website
We build and operate mirror websites that are difficult to block using an approach called Collateral Freedom. For more information see https://unblock.cn.com or contact greatfire@greatfire.org.FROM https://github.com/greatfire/redirect-when-blocked
---------------------------------
Website-mirror-by-proxy
Website-mirror-by-proxy is a server-side web proxy designed to host one or multiple dynamic mirror versions of any website. It is based on https://github.com/greatfire/redirect-when-blocked (the full edition). Whereas redirect-when-blocked requires the source/origin website to be modifed, website-mirror-by-proxy runs separately and does not need any modification of the source/origin website.
How to set up
- Install the required dependencies. If you are using Ubuntu or a similar OS you can use the install.sh script. Otherwise, manually install/enable Apache, the Apache rewrite module, PHP and the PHP HTTP extension (http://php.net/manual/en/book.http.php). It has to be version 1 of the HTTP extension since version 2 is not backward compatible. The specific version used in the install script and which this project has been tested successfully on is pecl_http-1.7.6.
- Copy conf-local-template.inc to conf-local.inc.
- In the conf-local.inc file, add the Conf::$default_upstream_base_url that you want to proxy. The URL should be formatted like this: scheme://domain, without any trailing slash or path. Example: http://example.com.
- Make sure that Apache is parsing .htaccess files in the site directory (eg "AllowOverride All").
- Add a list of one or more URLs where the site can be accessed to public/rwb/conf/alt_base_urls.txt. Each URL should include a trailing slash (eg http://localhost/website-mirror-by-proxy/public/ or http://example.com/).
- Optionally add a list of one or more third-party URLs, where the user should be redirected to if all of the mirror URLs fail, to public/rwb/conf/alt_url_collections.txt.
- Access the site...
Other platforms
This project could run on older versions of PHP, without the HTTP Extension, by replacing the HttpRequest, HTTPMessage etc with other compatible classes. It could run on servers other than Apache by adapting the .htaccess/rewrite functionality. It could also be wholly ported to a non-PHP environemnt, though such an initiative should probably start by porting redirect-when-blocked itself first.FROM https://github.com/greatfire/website-mirror-by-proxy