diff options
author | mms <michal@sapka.me> | 2024-03-04 19:40:15 +0100 |
---|---|---|
committer | mms <michal@sapka.me> | 2024-03-04 19:40:15 +0100 |
commit | 72371c30c3561b8dc5db01d19f947442e1a7ad8b (patch) | |
tree | 5ebc6e3524122894dc1f12cac50b781bd20af521 /content/bsd/relayd-custom-webserver.md | |
parent | bcb508a778fb6618a6f884302d91e9cc4666df4c (diff) |
chore: move openbsd to org
Diffstat (limited to 'content/bsd/relayd-custom-webserver.md')
-rw-r--r-- | content/bsd/relayd-custom-webserver.md | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/content/bsd/relayd-custom-webserver.md b/content/bsd/relayd-custom-webserver.md index a361fc2..605788b 100644 --- a/content/bsd/relayd-custom-webserver.md +++ b/content/bsd/relayd-custom-webserver.md @@ -1,38 +1,39 @@ ---- -title: "forwarding requests from Relayd to custom webserver" -category: -- bsd -abstract: How to forward requests to a webserver? -date: 2023-07-19T12:27:54+02:00 -year: -draft: false -tags: ---- -One thing that OpenBSD doesn't provide (yet?) is an HTTP proxy. I use [Plausible](https://plausible.io/)[^nope] for basic visitor analytics [^privacy] here, and one of the cool things you can do is to break all adblockers via serving Plausible from my own domain[^adblock] -[^privacy]: Yes, I want to know what people are reading! For details, refer to my [two sence long privacy policy](https://michal.sapka.me/about/#privacy-policy). -[^nope]: [this is no longer the case](https://michal.sapka.me/site/updates/2023/removed-plausible/) -[^adblock]: yes, it's a dick move. But my reasoning was simple: Plausible gathers so little information that the harm is almost nonexistent, and I really want to know what people are reading. - -After two evenings of failed attempts, I reminded myself that I am a programmer, and I wrote one myself. You can find it on my [VCS page](https://vcs.sapka.me/plaprox/). It was a great learning exercise and a chance to touch Golang[^ruby] for the first time. -[^ruby]: I am a Ruby developer by trade and heart, but I will try anything that is not an IDE-driven language. LSP for Java/Scala is still a joke, and I refuse to pollute my system with Intellij. [Go](https://go.dev/), on the other hand, is a modern language designed for humans. I am not good at it, but I am infinitetly[^infinit] better than a week ago. -[^infinit]: Any positive number would be infinite progress compared to zero, or as an old wise man once said: "to have a nickel and to not a nickel is already two nickles". - -Assuming you have it running (it works on my machine!), let's adjust our relayd(8). Plaprox listens on port 9090, and we want to relay all requests to `/js/script.js` there. ++++ +title = "OpenBSD: Forwarding requests from Relayd to a custom webserver" +author = ["MichaĆ Sapka"] +date = 2023-07-19T19:30:00+02:00 +categories = ["bsd"] +draft = false +weight = 2003 +abstract = "How to forward request to webserver?" +[menu] + [menu.bsd-openbsd] + weight = 2003 + identifier = "openbsd-forwarding-requests-from-relayd-to-a-custom-webserver" + name = "Forwarding requests from Relayd to a custom webserver" ++++ + +One thing that OpenBSD doesn't provide (yet?) is an HTTP proxy. +I use [[Plausible](https://plausible.io/)[^fn:1] for basic visitor analytics [^fn:2] here, and one of the cool things you can do is to break all adblockers via serving Plausible from my own domain[^fn:3] + +After two evenings of failed attempts, I reminded myself that I am a programmer, and I wrote one myself. +You can find it on my [no longer available]. +It was a great learning exercise and a chance to touch Golang[^fn:4] for the first time. + +Assuming you have it running (it works on my machine!), let's adjust our relayd(8). +Plaprox listens on port 9090, and we want to relay all requests to `/js/script.js` there. Let's add it to our relays in `relayd.conf`: -{{<highlight shell "linenos=inline">}} +```shell { linenos=true, linenostart=1 } table <plausibleproxyd> { 127.0.0.1 } http protocol "https" { - # all our previous content omitted - match request quick path "/js/script.js" forward to <plausibleproxyd> match request quick path "/api/event" forward to <plausibleproxyd> } - relay "https" { listen on 0.0.0.0 port 443 tls protocol https @@ -45,14 +46,27 @@ relay "https6" { forward to <httpd> port 8080 forward to <plausibleproxyd> port 9090 } -{{</highlight>}} +``` You can also move the port number to a table. -Remember that in Relayd(8) last one wins. We already have a match for the domain and added another matcher for the path. The request will be forwarded to the last marching matcher - so we put our new matchers at the end of the protocol definition. +Remember that in Relayd(8) last one wins. +We already have a match for the domain and added another matcher for the path. +The request will be forwarded to the last marching matcher - so we put our new matchers at the end of the protocol definition. + -## Updates +## Updates {#updates} -2023-07-28: remove wrong information abot PF. +2023-07-28: remove wrong information abot PF. 2023-07-30: fix invalid cron format 2023-12-12: extracted to a dedicated article + +[^fn:1]: [this is no longer the case](https://michal.sapka.me/site/updates/2023/removed-plausible/) +[^fn:2]: Yes, I want to know what people are reading! + For details, refer to my [two sence long privacy policy](https://michal.sapka.me/about/#privacy-policy). +[^fn:3]: yes, it's a dick move. + But my reasoning was simple: Plausible gathers so little information that the harm is almost nonexistent, and I really want to know what people are reading. +[^fn:4]: I am a Ruby developer by trade and heart, but I will try anything that is not an IDE-driven language. + LSP for Java/Scala is still a joke, and I refuse to pollute my system with Intellij. + [[<https://go.dev/>][Go][, on the other hand, is a modern language designed for humans. I am not good at it, but I am infinitetly[^fn:5] better than a week ago. +[^fn:5]: Any positive number would be infinite progress compared to zero, or as an old wise man once said: "to have a nickel and to not a nickel is already two nickles". |