7c01bb4b15f1b9e0b8329e39a52136cd9569475a — abyxcos 3 years ago acc5635
Introducing naughty.st
1 files changed, 19 insertions(+), 0 deletions(-)

A 2021-05-21-introducing_naughty_st.md
A 2021-05-21-introducing_naughty_st.md => 2021-05-21-introducing_naughty_st.md +19 -0
@@ 0,0 1,19 @@
# Introducing naughty.st
[Naughty.st](https://naughty.st) is a small little service to redirect one domain to another while preserving the rest of the URL. This is best used for redirecting links to services such as Twitter or Youtube to their free/open/less annoying counterparts such as Nitter or Cloudtube/Invidious. Even if you don't care about the privacy of these services, not having your page bogged down by over-use of Javascript or sitting through a minute of ads for a 15 second video or simply having a better connection to your locally hosted instance might be of interest. 

## Why not use X?
If you had this same exact problem and found a solution to it already, definitely stick with that. I ran in to a lot of partial solutions though so I ended up making this. 

### Rewriting URLs with a proxy
Rewrites was the first thing I tried; I found it ended up being a huge pain to intercept all SSL traffic, and then a rewrite caused all kinds of chaos when the expected/pinned certificates did not match the redirected site. If you have the tools to properly set this up on your network and all your devices, rewriting URLs at the proxy is by far the best way to go. But for me this was just adding more complications to my network and still not working in most cases. 

### Browser addons
If you only use one browser and it has an addon to redirect/rewrite URLs and links, that's great. I use multiple browsers on multiple devices, and most mobile browsers don't have good (or any) addon support. On top of that, the list of sites you are redirecting to slowly get out of sync between all the addons over time. Naughty.st provides you a single place to update that list, and if a service goes down it becomes simple to swap out the URLs. It is also easy to integrate naughty.st in to addons to remove the list synchronization problem. There is already an iOS share sheet shortcut and I plan to create addons for other browsers.

## Is it safe to use naughty.st directly or should I self host?
There is no logging on naughty.st, but you also have no way to verify the code I am running on my server is what you see in the repository. I tried to make naughty.st as easy as possible to self-host and the iOS shortcut doesn't hard-code the service URL. 

## How does naughty.st work?
I definitely recommend looking at the [code](https://git.sr.ht/~abyxcos/naughty.st/tree/master/item/naughty.st.go) as it's pretty simple even if you're not familiar with golang. Naughty.st starts up on port `:8476` and then sends any request it receives to the function named `urlHandler()`. `urlHandler()` does some sanity checking rather than just passing garbage or something unintended to the service (say by being triggered on a page we don't support). After that, it's just a simple switch/case and matching on the host names of the services. If a match is found, the host name in the URL structure is swapped out (all these services use compatible URL formats) and then naughty.st returns a standard HTTP redirect to let your browser do all the hard work. Naughty.st never has to look at the content of either of the pages to preform this action. If a match isn't found, a helpful message is returned.

tags: naughty.st golang release