8000 GitHub - sole/fedi-redi: Redirects and proxies so you can get vanity fediverse URLs with PHP+Apache
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ fedi-redi Public

Redirects and proxies so you can get vanity fediverse URLs with PHP+Apache

Notifications You must be signed in to change notification settings

sole/fedi-redi

Repository files navigation

fedi-redi

A naive PHP+Apache implementation of the redirections and proxying necessary to obtain a beautiful vanity URL for Mastodon. So even if you host your instance in a subdomain, you can still refer your friends to your top-level domain instead.

E.g. your Mastodon server points to mastodon.example.com but you don't want your friends to have to follow @user@mastodon.example.com - you want them to follow @user@example.com

Based on information from...

Installation

Assuming that:

  • you control the domain: my-super-cool-domain.tld
  • your mastodon server is in a subdomain: masto.my-super-cool-domain.tld
  1. Get a copy of this project.
  2. Place the files in the root folder of your top level domain, i.e. where you want your Mastodon URLs to appear to be. But watch out if you already have an .htaccess, you'll need to manually merge them (see Limitations section below). With our example, you place the files in the root of my-super-cool-domain.tld.
  3. Edit .htaccess and to replace {YOUR_DOMAIN} with the name of your mastodon server (for example: masto.my-super-cool-domain.tld).
  4. Rename config-dist.php to config.php and customise it: change the value of redirect_to_server to the URL of the Mastodon server you're using.

Now requests to ${your_domain}/@your_user and other requests to well-known files should be automatically redirected and/or or proxied appropriately.

Features

Assuming that $redirect-to-server is the value of your mastodon server and you followed the config steps above...

  • proxies .well-known/webfinger to $redirect-to-server/.well-known/webfinger
  • redirects .well-known/host-meta to $redirect-to-server/.well-known/host-meta
  • proxies .well-known/nodeinfo to $redirect-to-server/.well-known/nodeinfo
  • redirects @user to $redirect-to-server/@user

Limitations

I've written this in a few hours and it's the first time I do this sort of well-known manipulation so if something breaks I would not be surprised. Proceed with caution.

My current server uses Apache so if you need nginx rules, you'll have to write them yourself! Have a look at .htaccess for what you need to do. Hopefully it's simple enough that it's not too hard. There are also some pointers in the post from Masto.host that explain how to do this in Nginx.

Also if your server already has content that conflicts (e.g. .htaccess or paths starting with an @ like the ones for the users), then this might clash to some degree.

Hopefully it is helpful. Contributions are welcome but please note this isn't intended to be a fully fledged project, more like a snippet of code for you to use or get started.

Good luck and happy federating! 🤩

Future work

I had issues following users from other servers. I think I have fixed it by not using the naive proxying I was doing before, and just using Apache redirections, as of this commit a19b885. I think that might close issue #1 as the issue sounded similar, but I find debugging this a bit tedious and I have not time to do it now.

I have a sort of a hunch that maybe it would be easier to just use more .htaccess rules for the rest of paths, but I haven't explored this yet. Just leaving it here as a note for the future when I have some free time again (or if/when things start breaking).

If you know of a way to debug these things without much suffering or if you know the answer to my hunch, feel free to leave a comment or open an issue. I might pick it up a few months later, but I will be grateful all the same!

Thank you.

About

Redirects and proxies so you can get vanity fediverse URLs with PHP+Apache

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0