# Running WRP on FreeBSD 15 for Red Baron 3.10

WRP (Web Rendering Proxy) makes modern websites usable from historical web
browsers. It runs Chromium on a modern machine, fetches and renders the modern
page there, and sends a much simpler representation to the old browser.

This setup uses FreeBSD 15.1, a Bastille jail named `rh42`, and Red Baron 3.10
from Red Hat Linux 4.2. WRP runs inside the jail in simple HTML mode.

## Installation

WRP is not available as an official FreeBSD package. The upstream project does,
however, publish a native amd64 FreeBSD binary. Chromium, which WRP needs for
rendering, is available through `pkg`.

Install Chromium inside the jail:

```sh
doas jexec rh42 pkg install -y chromium
```

Download WRP 4.10.3 inside the jail:

```sh
doas jexec rh42 fetch -o /tmp/wrp-amd64-freebsd \
  https://github.com/tenox7/wrp/releases/download/4.10.3/wrp-amd64-freebsd
```

Verify the download against the SHA-256 digest published by GitHub:

```sh
doas jexec rh42 sha256 -c \
  2d433c5fea4aa29906f68a8d366cb18025e8f1fab74a31a89c5f3d311ca91d7d \
  /tmp/wrp-amd64-freebsd
```

Install the binary and remove the downloaded copy:

```sh
doas jexec rh42 install -o root -g wheel -m 0555 \
  /tmp/wrp-amd64-freebsd /usr/local/bin/wrp
doas jexec rh42 rm /tmp/wrp-amd64-freebsd
```

The release is tagged 4.10.3, although its startup log identifies itself as
4.9.3. This appears to be an upstream version-string oversight; the installed
binary's checksum matches the 4.10.3 release asset.

## Red Baron compatibility change

No Go source changes or recompilation were necessary. The WRP executable is
byte-for-byte identical to the upstream release.

Two runtime choices were needed for Red Baron:

1. Use standard GIF (`-t gif`) instead of WRP's default GIP encoder.
2. Change WRP's web form from POST to GET.

Red Baron could load WRP's front page, but submitting a URL through the original
POST form produced no request in the WRP log. A GET form works with this old,
Mosaic-derived browser.

WRP supports an external UI template, so the compatibility fix can be made
without patching the program. Download the matching upstream template:

```sh
doas jexec rh42 fetch -o /usr/local/etc/wrp.html \
  https://raw.githubusercontent.com/tenox7/wrp/4.10.3/wrp.html
```

Change the form method:

```sh
doas jexec rh42 sed -i '' \
  's/METHOD="POST"/METHOD="GET"/' /usr/local/etc/wrp.html
```

That is the only modified file. The resulting line is:

```html
<FORM ACTION="/" METHOD="GET">
```

## Starting WRP

Run WRP persistently under FreeBSD's `daemon(8)`:

```sh
doas jexec rh42 daemon \
  -p /var/run/wrp.pid \
  -o /var/log/wrp.log \
  /usr/local/bin/wrp \
  -l 127.0.0.1:8080 \
  -m html \
  -t gif \
  -ui /usr/local/etc/wrp.html \
  -b /usr/local/bin/chrome
```

The loopback binding deliberately limits WRP to clients inside the jail. WRP
can fetch arbitrary URLs, so binding it to every interface would expose an open
web proxy unless firewalling or authentication is added.

Open the following address in Red Baron:

```text
http://127.0.0.1:8080/
```

If Red Baron previously loaded the stock interface, reload the page so its cache
does not retain the POST version.

## Testing simple HTML mode

The interface should show HTML mode and GIF as the selected defaults. Enter:

```text
http://wikipedia.org
```

The server-side path can also be tested from inside the jail:

```sh
doas jexec rh42 fetch -qo /tmp/wrp-wikipedia.html \
  'http://127.0.0.1:8080/?url=http%3A%2F%2Fwikipedia.org&m=html&t=gif&s=200'

doas jexec rh42 grep -m 1 'The Free Encyclopedia' \
  /tmp/wrp-wikipedia.html
```

The test should print a line containing `The Free Encyclopedia`. Runtime
activity and errors are recorded in `/var/log/wrp.log` inside the jail.

## Useful administration commands

Check that WRP is listening:

```sh
doas jexec rh42 sockstat -4 -l | grep 8080
```

View its log:

```sh
doas jexec rh42 tail -f /var/log/wrp.log
```

Stop it safely using its PID file:

```sh
doas jexec rh42 kill "$(doas jexec rh42 cat /var/run/wrp.pid)"
```

Project: https://github.com/tenox7/wrp

