Micro.blog as site's subdirectory

I have my personal website at https://basus.me. I would like to use Micro.blog to run a subdirectory at a subdirectory, like https://basus.me/blog. I know it’s fairly straightforward to have the micro.blog be at a subdomain like blog.basus.me, but I’m not sure how easy or difficult it would be to have it at a subdirectory instead. I would like it to look and feel like the rest of my site as much as possible.

It’s not a feature built-in to Micro.blog, but it could be accomplished by configuring your personal site’s web server, NGINX, the right way. Easy or not, as always, is subjective. :blush: If you feel up for it, you’ll want to configure a reverse proxy.

But, if the end goal is to serve your blog from a subdirectory on your personal site and have it look and feel like the rest of your site, you could do it the other way around. Migrate your personal site’s pages over to Micro.blog and point your personal domain to your new Micro.blog home. From what I can tell, there’s not much to gain in having the two separated on different platforms.

I managed to get something close working using Nginx reverse proxy on the server that runs the rest of my website. This is the relevant snippet that I’m using:

 location /blog/ {
    proxy_ssl_server_name on;
    proxy_pass http://basus.micro.blog/;
    proxy_redirect https://basus.micro/blog/ /blog/;

It redirects from my blog/ subdirectory to Micro.blog without issue. The only thing missing is that the browser shows the Micro.blog URI in the address bar, but I don’t think there’s any way around that without changes on the Micro.blog end. I don’t want to bring my whole site to Micro.blog because I want to be able to do more experimental things with it.

I am almost positive that what you’re describing is pretty much the fundamental difference between what a subdomain can be used for versus a subdirectory.

There can be only one DNS entry for the subdomain. You cannot have separate DNS entries for a subdirectory.

If NGINX redirects to the Micro.blog domain, something is up with the configuration. Troubleshooting is needed, it looks like the .blog top-level domain is missing from https://basus.micro/blog/.

And there’s probably more stuff you want to do. For example, the HTML you get from Micro.blog will be full of links that look like https://basus.micro.blog/2020/02/24/feed-readers-really.html that needs to end up as https://basus.me/blog/2020/02/24/feed-readers-really.html. One way to handle that is via sub_filter directives.

A pretty decent chunk of my early career involved proxying old, often insecure, systems to expose them securely on the open web. There will be some work to get this to run smoothly, iron away all quirks, and fix edge cases. But if you’re motivated, it’s definitely doable.

Again, it would probably be easier to move everything over to Micro.blog. You could still have a reverse proxy in front for doing experiments. But it would be less difficult to configure as you don’t have to worry about serving from a subdirectory, with HTML rewrites and whatnot. That’s how I’ve set up my Micro.blog.

Another option, if you’re willing to let go of the idea that your Micro.blog needs to be server from a blog subdirectory, is to set up your Micro.blog to be severed from basus.me and configure NGNIX is so that it prioritize serving local files (from your self-hosted Hugo site) but, if nothing is found there, do a proxy request to your remote Micro.blog hosted Hugo blog.

I managed to get proxying with rewriting working with the following snippet:

location /stream/ {
     proxy_ssl_server_name on;
     proxy_pass https://basus.micro.blog/;
     proxy_redirect off;
     sub_filter "https://basus.micro.blog" "https://basus.me/stream";
     sub_filter_once off;

You can see the results at my website with the stream correctly proxying to my micro.blog site. I’ve also been hacking together a custom theme so that everything looks the same. Probably going to keep tinkering with it on and off, but I like it so far.

1 Like

Today I learned. I’ve never seen that.

1 Like