Skip to content

When launching containerized Chromium, use Tailscale with TS_AUTHKEY#69

Merged
ariya merged 2 commits intomainfrom
launch-chromium-tailscale
Dec 18, 2025
Merged

When launching containerized Chromium, use Tailscale with TS_AUTHKEY#69
ariya merged 2 commits intomainfrom
launch-chromium-tailscale

Conversation

@ariya
Copy link
Contributor

@ariya ariya commented Dec 18, 2025

If CDP_URL is not given, then try to launch a containerized Chromium (using chromium-live image).

However, if TS_AUTHKEY is supplied, there is no need to launch that containerized Chromium with host networking. Instead, use it to install and setup Tailscale (with that given TS_AUTHKEY).

To try, find that auth key for devices in Tailscale admin and then:

TS_AUTHKEY=yourkey uv run middleman.py

After a while, the tailnet IP address of the launched container will be shown:

✘ No existing CDP found
⇢ Launching local Chromium container with Tailscale...
✓ Container started: name=chromium-n9vap id=f89421629271
⇢ Setting up Tailscale in container f89421629271eee
⇢ Executing Tailscale setup: Step 1/4
⇢ Executing Tailscale setup: Step 2/4
⇢ Executing Tailscale setup: Step 3/4
⇢ Executing Tailscale setup: Step 4/4
✓ All Tailscale setup steps completed successfully
✓ Tailscale IP address: 100.84.70.110
✓ Set CDP_URL to http://100.84.70.110:9222
⇢ Checking CDP availability...
⇢ Checking for remote Chrome with CDP at http://100.84.70.110:9222...
✓ CDP is detected.
✓ Local Chromium CDP is ready
Listening on port 3000
INFO:     Started server process [595678]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:3000 (Press CTRL+C to quit)
image

Use a web browser to see the live view, in this example it will be at 100.84.70.110:3001. This is the remote containerized Chromium dynamically launched by Middleman during its initial bootstrap.

image

While watching the above live view, open Middleman example page as usual at localhost:3000 and click on the NPR example. The live view should show Chromium navigating to the NPR website for the headlines extraction.

If CDP_URL is not given, then try to launch a containerized Chromium (using
chromium-live image).

However, if TS_AUTHKEY is supplied, there is no need to launch that
containerized Chromium with host networking. Instead, use it to install
and setup Tailscale (with that given TS_AUTHKEY).

To try, find that auth key for devices in Tailscale admin and then:

```bash
TS_AUTHKEY=yourkey uv run middleman.py
```

After a while, the tailnet IP address of the launched container will be shown:

```
✘ No existing CDP found
⇢ Launching local Chromium container with Tailscale...
✓ Container started: name=chromium-n9vap id=f89421629271
⇢ Setting up Tailscale in container f89421629271eee
⇢ Executing Tailscale setup: Step 1/4
⇢ Executing Tailscale setup: Step 2/4
⇢ Executing Tailscale setup: Step 3/4
⇢ Executing Tailscale setup: Step 4/4
✓ All Tailscale setup steps completed successfully
✓ Tailscale IP address: 100.84.70.110
✓ Set CDP_URL to http://100.84.70.110:9222
⇢ Checking CDP availability...
⇢ Checking for remote Chrome with CDP at http://100.84.70.110:9222...
✓ CDP is detected.
✓ Local Chromium CDP is ready
Listening on port 3000
INFO:     Started server process [595678]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:3000 (Press CTRL+C to quit)
```

Use a web browser to see the live view, in this example it will be at
100.84.70.110:3001. This is the remote containerized Chromium dynamically
launched by Middleman during its initial bootstrap.

While watching the above live view, open Middleman example page as usual
at localhost:3000 and click on the NPR example. The live view should show
Chromium navigating to the NPR website for the headlines extraction.
middleman.py Outdated
if os.getenv("TS_AUTHKEY"):
if asyncio.run(launch_tailscaled_chromium()) is False:
print("Fatal error: Unable to detect or launch Chromium with Tailscale!")
# sys.exit(-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is exit still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I think it's better to remove it. Without a working containerized Chromium, Middleman will not effectivly work (i.e. unable to distill pages) but having it running means someone can drop in and perform some troubleshooting.

cmd = [
"run",
"-d",
"--rm",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we want to rm the container right away?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Middleman does not have any code that stop or kill the container anyway.

@ariya ariya merged commit 3de502b into main Dec 18, 2025
3 checks passed
@ariya ariya deleted the launch-chromium-tailscale branch December 18, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants