Ancestors

Toot

Written by adamghill on 2025-01-18 at 13:54

Any suggestions for a simple way in #Django to blackhole all these requests for Wordpress things which will never work?

=> View attached media

=> More informations about this toot | More toots from adamghill@indieweb.social

Descendants

Written by adamghill on 2025-01-18 at 13:57

I’m using Coolify with uses Caddy under the hood (I think) so maybe I can exclude some paths in a config or something. 🤔 #Django

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by {Insert Pasta Pun} on 2025-01-18 at 13:57

@adamghill a WAF like modsec or OWASP coraza https://github.com/corazawaf/coraza-caddy

=> More informations about this toot | More toots from risottobias@tech.lgbt

Written by adamghill on 2025-01-18 at 14:19

@risottobias That seems like more than I'm willing to deal with at this point. 😅

Adding this to my Caddyfile seems... not terrible?

@blackhole {
  path_regexp (^/wordpress.*|^/wp-admin.*)
}
handle @blackhole {
  respond 404
}

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Josh Thomas on 2025-01-18 at 14:40

@adamghill my first thought was a small middleware that checks the request path and blackholes any requests to php files, but going up a level from an application solution to the proxy itself is probably better?

=> More informations about this toot | More toots from josh@joshthomas.dev

Written by adamghill on 2025-01-18 at 15:01

@josh Yeah, seems like middleware (with some headers on the response?) and/or robots.txt is the simplest approach. Stopping the requests at the proxy feels like the “right" way to do it, though.

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Josh Thomas on 2025-01-18 at 15:15

@adamghill I’ve done similar middleware for applications running on Fly where I don’t really have access to the proxy level (without shoving my own proxy in there). It works and as long as you do the check early and efficiently (using eg compiled regex matching) I haven’t noticed any major perf issues. I can get away with it because they aren’t super traffic heavy; I imagine at bigger scales you’d want to go straight to the proxy to avoid overloading your app.

=> More informations about this toot | More toots from josh@joshthomas.dev

Written by adamghill on 2025-01-18 at 15:30

@josh Well, my side projects aren't lighting the world on fire (yet) so I might just make a middleware and be done with it!

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Jeff Triplett on 2025-01-18 at 15:30

@josh @adamghill If you use Cloudflare (free version) and I would assume Fastly, they can do it for you.

=> More informations about this toot | More toots from webology@mastodon.social

Written by adamghill on 2025-01-18 at 15:49

@webology @josh Good call -- gonna look at my Cloudflare setup.

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Josh Thomas on 2025-01-18 at 15:54

@adamghill @webology beyond just the page rules, it takes a trivial amount of JS in a Cloudflare worker to do this too https://developers.cloudflare.com/workers/examples/redirect/

=> More informations about this toot | More toots from josh@joshthomas.dev

Written by adamghill on 2025-01-18 at 16:10

@webology @josh omg Cloudflare WAF where have you been all my life 😍

=> View attached media | View attached media

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Jeff Triplett on 2025-01-18 at 17:17

@adamghill @josh It's on my list to automate this since they have an API but I haven't gotten there yet.

I'm mentioning this because that means Josh will figure it out before I have time even to look. 🤣

=> More informations about this toot | More toots from webology@mastodon.social

Written by adamghill on 2025-01-18 at 17:23

@webology @josh I wonder if a management command might be useful

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Josh Thomas on 2025-01-18 at 18:04

@webology @adamghill Naw, my hyper focus is oscillating between component templates and language servers, I don’t think there’s room for anything more right now 😅

=> More informations about this toot | More toots from josh@joshthomas.dev

Written by adamghill on 2025-01-18 at 18:20

@josh @webology focus?! What is this “focus” that you speak of

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Josh Thomas on 2025-01-18 at 15:51

@webology @adamghill Oh yeah 👍, I’ve used the page rules in Cloudflare to do the same thing too. I just wish there was a way to declare them and keep them in the repo instead of needing to set them up in the web ui.

=> More informations about this toot | More toots from josh@joshthomas.dev

Written by Dan Sloan on 2025-01-19 at 02:11

@josh @webology @adamghill Indeed. I do all my infra stuff with python code using Pulumi, either in same repo or for bigger projects in a separate related IaC repo. Pulumi has https://www.pulumi.com/registry/packages/cloudflare/ which I do use a bit.

=> More informations about this toot | More toots from LucidDan@fosstodon.org

Written by Jeff Triplett on 2025-01-19 at 03:38

@LucidDan @josh @adamghill That's pretty neat. I'll have to check it out.

=> More informations about this toot | More toots from webology@mastodon.social

Written by Dan Sloan on 2025-01-19 at 03:44

@webology @josh @adamghill I spent years beating my DevOps head against Terraform HCL configs, and last year finally found Pulumi as an alternative. Have now moved all my devops stuff that I own to Pulumi, no regrets.

It's remarkably simple to get going with it. https://github.com/pulumi/examples has some good simple demos. You can use it for as much or little as you want, I have some cases where all I'm doing is managing some DNS records.

=> More informations about this toot | More toots from LucidDan@fosstodon.org

Written by David Guillot on 2025-01-18 at 14:39

@adamghill Django is not the best place to do that, since you probably don't want these requests to even reach Django. Your reverse proxy is the right place, whether it's httpd, nginx, or modern stuff like traefik or caddy.

=> More informations about this toot | More toots from david_guillot@social.tchncs.de

Written by adamghill on 2025-01-18 at 14:58

@david_guillot Yup! I was just playing with Coolify's caddy configuration and broke all my sites for a few minutes, so gonna back away from this slowly and maybe look at it again later. 😂

=> More informations about this toot | More toots from adamghill@indieweb.social

Written by Benjamin Balder Bach on 2025-01-19 at 11:52

@adamghill @david_guillot one of the things I love about nginx is that it doesn't restart and crash when I mess up the config and reload it (on a VPS)

If you are using Docker, you can try to add caddy validate to your Dockerfile - which is the equivalent of nginx -t (test the configuration)

=> More informations about this toot | More toots from benjaoming@social.data.coop

Written by Josh Thomas on 2025-01-18 at 15:05

@david_guillot @adamghill Yep what he said 👆

=> More informations about this toot | More toots from josh@joshthomas.dev

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113849694296538983
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
401.886222 milliseconds
Gemini-to-HTML Time
10.31506 milliseconds

This content has been proxied by September (ba2dc).