Skip to content

Installation

Daylin Cooper edited this page Jan 1, 2024 · 21 revisions

Automatic installation

Currently, there are no solutions to automatically install Rehike. Rehike is still in active development, and should be considered "use at your own risk" at the moment.

Manual installation

Manual installation entails installing of the prerequisites in order to set up your own Rehike development environment.

Although Rehike has tried hard to maintain minimal dependencies, this may change in the future as the scope of the project broadens. For example, we may introduce additional technologies in order to compile certain source code.

Although Rehike may look intimidating to install, it actually just requires a few programs and some lightweight editing. Most of the work could be automated, but we have been too lazy to develop the tooling for an automatic installation :P

In addition to the current development resources, here are some community resources for speakers of other languages or those who would prefer to watch a video tutorial:

Alternative tutorials

Text tutorials in other languages

Video tutorials

Prerequisites

The current prerequisites in order to install Rehike are:

  • Windows 7 (64-bit) or later, or equivalences for other operating systems.
    • As nice as it would be to support a 21 year old operating system, unfortunately the PHP runtime itself has imposed this limit upon us.
      • That being said, you can use Rehike on older operating systems by hosting the server on a newer operating system, either on another computer or within a virtual machine.
    • Windows Vista with the Extended Kernel will work too.
    • For macOS, Mac OS X 10.7 or greater is required.
  • PHP 8.0 or greater
    • For the layman, XAMPP is the preferred easy solution for Windows environments.
    • If you're using Linux, the default PHP distribution in your package manager may not come with all of the required extensions.
  • A method to proxy Rehike to www.youtube.com.

Other recommended software that aren't required to run Rehike:

  • For Windows and macOS users, the recommended way of managing versions is via Git. Unlike Linux, you will have to manually install it manually.

Installing XAMPP

The first application you will want to install is XAMPP. This is an Apache Webserver distribution (along with a few other components), which will run the Rehike server. Rehike is currently not tested with other webservers.

For Rehike, only the following XAMPP components are required. You may install all of them, especially if you wish to use the development environment for anything else, but otherwise you can disable everything else:

XAMPP components

After, you have installed XAMPP, open the program called "XAMPP Control Panel" and you should see the following interface:

Initial XAMPP interface, dictating installation by clicking the start button in the interface.

Click the buttons in the order presented in the image in order to set up the Apache Webserver component.

⚠️ WARNING ⚠️

Do NOT install Apache as a service by clicking the checkbox in XAMPP Control Panel. Although this may seem tempting as it makes Apache run at startup, it also introduces a security risk as this runs as NT AUTHORITY\SYSTEM, which gives Rehike the permission to do whatever it wants. This also means that malware can rely on Apache being a service and any possible bugs in Rehike (or other PHP scripts that can be accessed) to take complete control of your system.

Instead, follow the the next section for the right way to make Apache run at startup.

Making Apache run at startup on Windows

The correct way to do this is to make it run under your own user account. Windows provides an easy way to make programs run at startup.

Simply open Run (Windows+R) and type shell:startup.

The Windows Run prompt which is told to open "shell:startup" in Windows Explorer.

In this folder, download OpenApache.vbs and move it into here.

OpenApache.vbs in the Startup folder.

And now Rehike should work at startup just as you'd hope.

⚠️ Problem notice!! ⚠️ - Apache not starting

You may encounter issues with the Apache server not starting.

This is most likely caused by another program somewhere taking up ports 80 or 443, which are the standard HTTP ports.

The most infamous culprits are:

  • Skype
    • Sorry, but you are shit out of luck. Complain to Microsoft, uninstall Skype, or change the Apache port. Skype used to allow changing this on older versions, but the option is removed as of Skype 8.
  • VMware Workstation
    • This may also occur on other VMware products, such as VMware Player.
    • If you are using VMware Workstation 16.0 specifically, you will not be able to change the port. They readded the option in 16.1, although I'm not sure the update policy or if you would need to relicense it.
    • Otherwise, the port can be trivially changed in the VMware options by going to Edit -> Preferences -> Shared VMs, where you need to change the port to something other than 443.

The other way to fix this is changing the Apache ports to something other than 80 and 443. If you do this, you will be unable to forward Rehike via hostsfile, and you will have to manually specify the port in the URL.

Setting up Rehike

Within the XAMPP installation (default: C:\xampp), there should be a folder inside called htdocs. This contains all the PHP code to be executed when you request the server.

For a simple installation, you can simply replace the contents of this folder with the contents of a Rehike download. This is highly discouraged. Use Git if possible.

To install with the command prompt:

cd C:\xampp
rmdir htdocs
git clone https://github.com/Rehike/Rehike htdocs

Now you should be able to go to localhost and see Rehike.

⚠️ Problem notice!! ⚠️ - macOS/Linux FS errors

On macOS and Linux, Rehike may crash at startup, and you will see the Rehike Fatal Error screen. This is because Rehike cannot write the configuration or cache files into its install directory.

If you get any error relating to files, run chmod -R 777 <dir> where <dir> is your XAMPP htdocs directory. This is /Applications/XAMPP/xamppfiles/htdocs and /opt/lampp/htdocs on macOS and Linux by default, respectively.

Branches!

As Rehike is in active development, certain features are only being worked on in a single dedicated branch, which will then be merged with the main one once the feature is determined to be complete enough.

The currently recommended branch is master.

You can take a look at the branches on the GitHub website, on the left side of the main repository page. On Git CLI, you can list all branches by simply typing git branch.

Switching to another branch on the GitHub website just means downloading the ZIP after clicking its link. With Git CLI, you can type git switch <branch name>.

If you downloaded Git, you also get the fun of being able to play Frankenstein with them! (Though you may to go in and change code conflicts if they arise...)

git merge <other branch name>

Once you've gotten to this point, you can test out if Rehike works by visiting 127.0.0.1 in your web browser. If you get a YouTube page, then Rehike is working.

Proxying Rehike via Hosts File

The hosts file is the recommended way to proxy Rehike, and alternative methods should be avoided if possible. In particular, proxy servers like Fiddler and mitmproxy will cause problems unrelated to YouTube browsing across your entire computer for as long as you are connected to the proxy server.

You will need to download these self-signed certificates. These are used to sign the traffic Rehike produces so that your browser recognises it as regular YouTube traffic.

Apache certificates

This download contains a zipped folder with three subdirectories. You can extract them anywhere, but it's good to put them with your Apache install. The recommended destinations are:

  • C:\xampp\apache\conf (Windows); replace the existing files.
  • /opt/lampp/etc (Linux); replace the existing files.
  • /Applications/XAMPP/xamppfiles/etc (macOS with XAMPP); replace the existing files.

But any destination will work as long as Apache can read them.

Setting up the Rehike server

Go to the following file:

  • C:\xampp\apache\conf\extra\httpd-vhosts.conf (Windows)
  • /opt/lampp/etc/extra/httpd-vhosts.conf (Linux)
  • /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf (macOS with XAMPP)

...and add the following definition to the end of it:

<VirtualHost 127.0.0.1:443>
   ServerName www.youtube.com
   DocumentRoot "C:/xampp/htdocs"
   SSLEngine on
   SSLCertificateFile "conf/ssl.crt/server.crt"
   SSLCertificateKeyFile "conf/ssl.key/server.key"
   <Directory "C:/xampp/htdocs">
      AllowOverride All
      Require all granted
   </Directory>
</VirtualHost>

Obviously, repoint file paths as needed. Linux users will probably have /opt/lampp/htdocs as their document root instead.

After editing your hosts file, you must restart Apache for the changes to take place. Open XAMPP Control Panel and click the stop button for Apache, and then click start after it shuts down.

Setting up the native redirection

The final step is getting the operating system to redirect Rehike on its own.

Go to the following file:

  • C:\Windows\System32\drivers\etc\hosts (you must open notepad as administrator)
  • /etc/hosts (sudo nano, etc.)

This file is responsible for manually defining DNS resolutions, but you don't really need to know the technicalities. Just add the following line:

127.0.0.1 www.youtube.com

After doing so, you may have to clear DNS cache or restart your computer (this is the case on Windows versions prior to 7 and probably some Linux versions).

Importing the certificate

Into your system

While importing the Rehike certificate into your browser should work fine mostly, certain other applications which use Electron or similar frameworks and embed YouTube content (Discord, Steam, etc.) will not pick up this certificate. For this reason, we recommend installing the certificate system-wide (or in the case of Windows, for your current user).

Windows

Run certmgr.msc, and open the context menu of Trusted Root Certification Authorities. Hover over All Tasks, and select Import....

Import...

Click Next once, and then click Browse... to the right of the File name text box. Change the file type filter on the bottom right to All Files (*.*). This is because while Windows supports .pem certificates, it is missing from this dialog box for an unknown reason. Locate rehike_master_cert.pem and choose it.

If you haven't downloaded this file, download it from the Browser certificate link here.

All Files (.)

Now, click through the rest of the wizard, and accept any warnings that pop up along the way. If you get a message box that says "The import was successful.", you've successfully installed the certificate.

The import was successful.

Into your browser

Sometimes, a system-wide certificate install won't apply to your browser (especially in the case of older Firefox). This is a general guide on how to install an SSL certificate into your browser. For this section, both screenshots from Chrome and Firefox will be demonstrated, although this should generally work for other browsers too.

On Firefox, the certificate manager can be opened by a button near the bottom of the "Privacy & Security" tab at about:preferences#privacy.

At the bottom of the "Privacy & Security" tab, under the "Certificates" section, click the "View Certificates" button.

On Chrome, it appears behind two pages. First, go to the "Privacy and security" tab and find the "Security" link. Then scroll to the bottom of that and click "Manage certificates".

On the "Privacy and Security" tab, near the bottom, click the "Security" link to be taken to the next page.

Then open the "Manage certificates" popup using the button at the bottom of that page.

After that, you want to go to the "authorities" tab and import the SSL certificate file into there. If it asks you what you're using it for, tick all boxes and continue.

Firefox's certificate manager. On the "Authorities" tab, you want to import it here. Chrome's certificate manager. On the "Trusted Root Certification Authorities" tab, you want to import it here.

Success?

Following these steps, you should successfully load Rehike without the use of any proxy/middleware.

If you wish to disable Rehike for a period of time, a convenient way is to go to /rehike/config and click the button to disable Rehike. Alternatively, you can use the URL parameter: ?enable_polymer=1.

Known limitations

Although it's advised to host Rehike on ports 80 and 443, some programs (particularly on Windows) hijack these ports for their own bullshit and will prevent Apache from starting. However, using a proxy allows you to change the Apache ports and forward YouTube to a non-standard port. This will not work with this approach using hosts file, since it just manages name to IP address resolution.

The simple solution is to stop using Skype, since it has no excuse to hijack :80 and :443 anyway.

Problems?

I tried to write these instructions in the friendliest manner that came to me, however you can't always be perfect.

Recheck your steps - you probably forgot something. Here are some examples of issues:

I get a "no connection" error on the YouTube layout

"Connect to the internet" error screen

This is always YouTube's cache hiding another issue. Because the Polymer loader document remains pretty much the same, they store it with a pretty long cache policy, so you don't download it a billion times whenever you visit YouTube from a bookmark or anything like that.

Press Ctrl+Shift+R or Ctrl+F5 to refresh the page without loading from cache. This will reveal the true error.

YouTube loads for me, but I don't get Rehike

This may be an alternate symptom of any of the mistakes you could make. Verify that Apache is running, that SSL is set up properly, that the definition is in hosts file, that the OS isn't caching DNS resolves, and that the browser isn't loading from cache (Ctrl+Shift+R or Ctrl+F5).

To refresh your DNS cache, run the following command:

  • ipconfig /flushdns (Windows)
  • sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder (macOS)
  • Linux instructions are case-specific; look up instructions for your distribution and configuration.

I get a certificate error in my browser

This is caused by an improper SSL configuration. Verify that the browser has the Rehike master certificate installed in your browser as an authority (it should be called "www.youtube.com" and be issued by "Taniko Yamamoto"), and that Apache is configured to use the corresponding SSL certificates.

Notes on Firefox

Sometimes, Firefox can have a level of security that is greater enforced than anything else.

I have no idea what ungodly combination of configuration options there are that could cause Rehike to break on Firefox, but the most notable one is security.cert_pinning.enforcement_level. If you are having any difficulty at all, set this to 0 in about:config.

I noticed that this is required for Waterfox. I am not sure if it will override the properties of certain autoconfig scripts, so you may need to modify the source code of those in the case that they are present.

For other legacy browsers

Legacy browsers had a feature called HTTP Public Key Pinning (HPKP). This is a technology that is no-longer used, and modern browsers usually do not have it because it was ironically very useful for holding hijacked sites hostage. If you ever visited YouTube before in your browser installation, you may have to do some additional work to get YouTube loaded.

I get nothing - page completely fails to load

The most likely cause of YouTube not responding at all, as if the website doesn't exist, is Apache not running. Try starting Apache and trying again.

Sometimes it can be our fault. This is certainly the case if Rehike loads in other cases. If this is the case, then an infinite loop has occurred in our code and should be reported to us.

yt-dlp won't download anything from YouTube

Pass the --no-check-certificates argument. This is because yt-dlp has its own certificate validation process that ignores the OS-wide one.

You can enable this for every single time you use yt-dlp by adding this parameter into the config file. That is, create a file at the following location:

  • %appdata%\yt-dlp\config.txt (Windows)
  • ~/.yt-dlp/config (Linux, macOS)

and add the following contents to the file:

--no-check-certificates

Alternate proxy methods

See the dedicated page on this matter.