wrp/README.md

215 lines
10 KiB
Markdown
Raw Normal View History

# WRP - Web Rendering Proxy
2019-06-01 01:28:48 +00:00
2024-07-12 04:40:13 +00:00
A browser-in-browser "proxy" server that allows to use historical / vintage web browsers on the modern web. It has two modes:
- ISMAP "graphical" mode, renders web page in to a GIF, PNG or JPG image with clickable imagemap.
- Simple HTML mode converts web page in to Markdown, then renders it into simplified HTML for old browsers.
2019-01-08 01:04:07 +00:00
2019-07-17 20:59:44 +00:00
![Internet Explorer 1.5 doing Gmail](wrp.png)
2022-12-10 11:59:30 +00:00
## Usage Instructions
2019-06-05 08:42:17 +00:00
2024-06-10 08:25:50 +00:00
* [Download a WRP binary](https://github.com/tenox7/wrp/releases/) run it on a machine that will become your WRP gateway/server. This should be modern hardware and OS. Google Chrome / Chromium Browser is required to be preinstalled. Do not try to run WRP on an old machine like Windows XP or 98.
2022-12-10 11:59:30 +00:00
* Make sure you have disabled firewall or open port WRP is listening on (by default 8080).
2022-11-29 14:57:31 +00:00
* Point your legacy browser to `http://address:port` of the WRP server. Do not set or use it as a "proxy server".
2022-11-30 07:45:01 +00:00
* Type a search string or a full http/https URL and click **Go**.
2024-07-12 04:40:13 +00:00
* Select whether you want to use graphical (ISMAP) or simple HTML mode.
### Image Map Mode
2021-03-08 12:48:51 +00:00
* Adjust your screen **W**idth/**H**eight/**S**cale/**C**olors to fit in your old browser.
2024-07-12 04:40:13 +00:00
* Scroll web page by clicking on the in-image scroll bar on the right.
2022-11-30 07:45:01 +00:00
* WRP also allows **a single tall image without the vertical scrollbar** and use client scrolling. To enable this, simply height **H** to `0` . However this should not be used with old and low spec clients. Such tall images will be very large, take a lot of memory and long time to process, especially for GIFs.
* Do not use client browser history-back, instead use **Bk** button in the app.
* You can re-capture page screenshot without reloading by using **St** (Stop). This is useful if page didn't render fully before screenshot is taken.
* You can also reload and re-capture current page with **Re** (Reload).
2022-11-30 07:45:01 +00:00
* To send keystrokes, fill **K** input box and press **Go**. There also are buttons for backspace, enter and arrow keys.
2024-07-12 04:40:13 +00:00
* If your browser supports it, prefer PNG over GIF/JPG. PNG is much faster, whereas GIF/JPG requires a lot of additional processing on both client and server to encode/decode.
2022-11-29 15:02:06 +00:00
* GIF images are by default encoded with 216 colors, "web safe" palette. This uses an ultra fast but not very accurate color mapping algorithm. If you want better color representation switch to 256 color mode.
2019-06-05 08:42:17 +00:00
2024-06-23 02:43:33 +00:00
### Simple HTML mode
2024-07-12 04:40:13 +00:00
* Select image type PNG/GIF/JPG. Each individual image from the original web site will be converted to the selected format.
* Type maximum image size in pixels.
2024-06-23 02:43:33 +00:00
2022-12-10 11:59:30 +00:00
## UI explanation
The first unnamed input box is either search (google) or URL starting with http/https
**Go** instructs browser to navigate to the url or perform search
**Bk** is History Back
**St** is Stop, also re-capture screenshot without refreshing page, for example if page
render takes a long time or it changes periodically
**Re** is Reload
**W** is width in pixels, adjust it to get rid of horizontal scroll bar
**H** is height in pixels, adjust it to get rid of vertical scroll bar.
It can also be set to 0 to produce one very tall image and use
client scroll. This 0 size is experimental, buggy and should be
used with PNG and lots of memory on a client side.
**Z** is zoom or scale
**C** is colors, for GIF images only (unused in PNG, JPG)
**K** is keystroke input, you can type some letters in it and when you click Go it will be typed in the remote browser.
**Bs** is backspace
**Rt** is return / enter
**< ^ v >** are arrow keys, typically for navigating a map, buggy.
2024-05-23 07:36:58 +00:00
### UI Customization
2021-02-08 16:07:09 +00:00
2022-11-30 07:45:01 +00:00
WRP supports customizing it's own UI using HTML Template file. Download [wrp.html](wrp.html) place in the same directory with wrp binary customize it to your liking.
2021-02-08 16:07:09 +00:00
2019-08-04 08:14:31 +00:00
## Docker
2019-08-04 07:51:55 +00:00
2024-06-23 02:59:11 +00:00
https://hub.docker.com/r/tenox7/wrp
2019-12-24 10:51:44 +00:00
```shell
2024-06-10 08:16:04 +00:00
$ docker run -d --rm -p 8080:8080 tenox7/wrp:latest
2019-06-04 09:20:43 +00:00
```
2024-06-10 08:16:04 +00:00
## AWS
2019-10-15 05:26:32 +00:00
2024-06-10 08:16:04 +00:00
It's possible to run WRP on AWS App Runner.
2019-10-15 05:26:32 +00:00
2024-06-10 08:16:04 +00:00
First you need to upload the Docker image to ECR - [Instructions](https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-push-ecr-image.html).
Create App Runner service using the uploaded image using the AWS Console or CLI.
2020-04-28 11:37:15 +00:00
2024-06-10 08:21:41 +00:00
[AWS Console](https://console.aws.amazon.com/apprunner/home#/create)
```shell
aws apprunner create-service --service-name my-app-runner-service --source-configuration '{
"ImageRepository": {
"ImageIdentifier": "<account_id>.dkr.ecr.<region>.amazonaws.com/wrp:latest",
"ImageRepositoryType": "ECR",
"ImageConfiguration": {"Port": "8000"},
"AutoDeploymentsEnabled": true
}
}' --instance-configuration '{
"Cpu": "1024",
"Memory": "2048",
"InstanceRoleArn": "arn:aws:iam::<account_id>:role/AppRunnerECRAccessRole"
}'
```
2020-04-28 11:37:15 +00:00
## Azure Container Instances
2020-04-27 08:49:55 +00:00
2024-06-10 08:16:04 +00:00
[Azure Console](https://portal.azure.com/#create/Microsoft.ContainerInstances)
CLI:
2020-04-27 08:49:55 +00:00
```shell
2024-05-23 08:05:26 +00:00
$ az container create --resource-group wrp --name wrp --image tenox7/wrp:latest --cpu 1 --memory 2 --ports 80 --protocol tcp --os-type Linux --ip-address Public --command-line '/wrp -l :80 -t png -g 1280x0x256'
2020-04-27 08:49:55 +00:00
```
2024-06-10 08:16:04 +00:00
## Google Cloud Run
```shell
$ gcloud run deploy --platform managed --image=tenox7/wrp:latest --memory=2Gi --args='-t=png','-g=1280x0x256'
```
2024-06-22 22:38:47 +00:00
Unfortunately Google Cloud Run forces you to use HTTPS, which likely won't work with old browsers.
2020-04-28 11:50:55 +00:00
2020-04-27 08:49:55 +00:00
2019-08-04 08:14:31 +00:00
## Flags
2019-08-04 07:51:55 +00:00
2022-11-30 07:59:43 +00:00
```text
-l listen address:port (default :8080)
2024-07-12 04:40:13 +00:00
-m mode, either ismap (graphical) or html
-t image type gif, png or jpg (default gif)
2022-11-30 07:59:43 +00:00
-g image geometry, WxHxC, height can be 0 for unlimited (default 1152x600x216)
C (number of colors) is only used for GIF
2024-07-12 04:40:13 +00:00
-q Jpeg image quality, default 75%
2022-11-30 07:59:43 +00:00
-h headless mode, hide browser window on the server (default true)
-d chromedp debug logging (default false)
2022-12-08 08:55:56 +00:00
-n do not free maps and images after use (default false)
2022-11-30 07:59:43 +00:00
-ui html template file (default "wrp.html")
2024-07-12 04:40:13 +00:00
-ua user agent, override the default "headless" agent (only for ismap mode)
2022-11-30 07:59:43 +00:00
-s delay/sleep after page is rendered before screenshot is taken (default 2s)
2019-08-04 07:51:55 +00:00
```
2019-07-17 07:49:36 +00:00
## Minimal Requirements
2020-04-27 22:52:11 +00:00
* Server/Gateway requires modern hardware and operating system that is supported by [Go language](https://github.com/golang/go/wiki/MinimumRequirements) and Chrome/Chromium Browser, which must be installed.
2020-04-26 09:30:16 +00:00
* Client Browser needs to support `HTML FORMs` and `ISMAP`. Typically [Mosaic 2.0](http://www.ncsa.illinois.edu/enabling/mosaic/versions) would be minimum version for forms. However ISMAP was supported since 0.6B, so if you manually enter url using `?url=...`, you can use the earlier version.
2019-07-17 07:49:36 +00:00
2024-06-10 08:39:37 +00:00
## FAQ
2020-04-26 09:30:16 +00:00
### I can't get it to run
2024-01-06 10:10:01 +00:00
This program does not have a GUI and is run from the command line. After downloading, you may need to enable executable bit on Unix systems, for example:
2022-12-10 11:59:30 +00:00
```shell
2020-04-26 07:17:18 +00:00
$ cd ~/Downloads
$ chmod +x wrp-amd64-macos
2024-01-06 10:10:01 +00:00
$ ./wrp-amd64-macos
```
### Websites are blocking headless browsers
2024-07-12 04:40:13 +00:00
This is a well known issue. WRP has some provisions to work around it, but it's a cat and mouse game. The first and foremost recommendation is to change the `User Agent`, so that it doesn't say "headless". Add `-ua="my agent"` to override the default one. Obtain your regular desktop browser user agent and specify it as the flag. For example:
2024-01-06 10:10:01 +00:00
```shell
$ wrp -ua="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
```
2024-06-10 08:39:37 +00:00
### Why is WRP called "proxy" when it's not
WRP originally started as true http proxy. However this stopped working because the whole internet is now encrypted thanks to [Let's Encrypt](https://en.wikipedia.org/wiki/Let%27s_Encrypt). Legacy browsers do not support modern SSL/TLS certs as well as [HTTP CONNECT](https://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_method) so this mode had to be disabled.
### Will you support http proxy mode in future?
2024-07-12 04:40:13 +00:00
Some efforts (ssl strip) are under way but it's very [difficult](https://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_method) to do it correctly and the priority is rather low.
2024-06-10 08:39:37 +00:00
2024-08-25 22:44:44 +00:00
### Why isn't there a Docker image for armv6
Because https://hub.docker.com/r/chromedp/headless-shell/ doesn't have one. WRP uses that image. If you have a fork that builds for armv6 let me know.
2019-07-13 08:23:34 +00:00
## History
2019-12-24 10:51:44 +00:00
2020-10-26 09:06:45 +00:00
* Version 1.0 (2014) started as a *cgi-bin* script, adaptation of `webkit2png.py` and `pcidade.py`, [blog post](https://virtuallyfun.com/2014/03/03/surfing-modern-web-with-ancient-browsers/).
* Version 2.0 became a stand alone http-proxy server, supporting both Linux and MacOS, [another post](https://virtuallyfun.com/wordpress/2014/03/11/web-rendering-proxy-update//).
2024-06-10 08:39:37 +00:00
* In 2016 thanks to [Let's Encrypt](https://en.wikipedia.org/wiki/Let%27s_Encrypt) the whole internet migrated to HTTPS/SSL/TLS and WRP largely stopped working. Python code became unmaintainable and there was no easy way to make it work on Windows, even under WSL.
2020-10-26 09:06:45 +00:00
* Version 3.0 (2019) has been rewritten in [Go](https://golang.org/) using [Chromedp](https://github.com/chromedp) as browser-in-browser instead of http-proxy. The initial version was [less than 100 lines of code](https://gist.github.com/tenox7/b0f03c039b0a8b67f6c1bf47e2dd0df0).
2024-05-23 07:36:58 +00:00
* Version 4.0 has been completely refactored to use mouse clicks via imagemap instead parsing a href nodes.
2022-11-30 07:45:01 +00:00
* Version 4.1 added sending keystrokes in to input boxes. You can now login to Gmail. Also now runs as a Docker container and on Cloud Run/Azure Containers.
2020-10-26 09:01:32 +00:00
* Version 4.5 introduces rendering whole pages in to a single tall image with client scrolling.
2022-11-29 14:57:31 +00:00
* Version 4.6 adds blazing fast gif encoding by [Hill Ma](https://github.com/mahiuchun).
2024-05-23 07:55:41 +00:00
* Version 4.6.3 adds arm64 / aarch64 Docker container support - you can run it on Raspberry PI!
2024-06-23 02:43:33 +00:00
* Version 4.7 add simple html aka reader aka text mode.
2024-07-12 04:40:13 +00:00
* Version 4.8 add image support to simple html mode.
2019-06-06 23:46:40 +00:00
2019-12-25 11:35:48 +00:00
## Credits
2019-12-24 10:51:44 +00:00
2019-06-10 22:14:17 +00:00
* Uses [chromedp](https://github.com/chromedp), thanks to [mvdan](https://github.com/mvdan) for dealing with my issues
2019-06-18 21:46:19 +00:00
* Uses [go-quantize](https://github.com/ericpauley/go-quantize), thanks to [ericpauley](https://github.com/ericpauley) for developing the missing go quantizer
2019-06-10 22:14:17 +00:00
* Thanks to Jason Stevens of [Fun With Virtualization](https://virtuallyfun.com/) for graciously hosting my rumblings
2019-07-14 08:40:17 +00:00
* Thanks to [claunia](https://github.com/claunia/) for help with the Python/Webkit version in the past
2022-11-30 07:45:01 +00:00
* Thanks to [Hill Ma](https://github.com/mahiuchun) for ultra fast gif encoding algorithm
2020-09-29 05:00:20 +00:00
* Historical Python/Webkit versions and prior art can be seen in [wrp-old](https://github.com/tenox7/wrp-old) repo
2019-06-18 21:48:39 +00:00
2024-06-10 07:24:56 +00:00
## Related
You may also be interested in:
* [VncFox](https://github.com/tenox7/vncfox)
* [Browservice](https://github.com/ttalvitie/browservice)
2024-06-16 23:24:41 +00:00
* [Browsh](https://github.com/browsh-org/browsh)
2024-06-10 07:24:56 +00:00
2019-06-18 21:48:39 +00:00
## Legal Stuff
2019-12-24 10:51:44 +00:00
2024-05-23 07:36:58 +00:00
```text
License: Apache 2.0
Copyright (c) 2013-2024 Antoni Sawicki
2024-01-06 10:10:01 +00:00
Copyright (c) 2019-2024 Google LLC
2024-06-16 23:24:41 +00:00
```