How I set my former MacBook Pro as a server

May 10th 2018

Futurology : Apple goes after the NAS market with HomeCloud

The ultimate geek quest, in my opinion, is ubiquity. I have always liked the idea of having my files accessible from anywhere. So I recently took the challenge to set up my former MacBook Pro as a personal server. It enables me to manage medias, file synchronization, and remote desktop/files access. Here is how I did it.

To be honest, I previously owned a Synology NAS - 213J - and as I said before, the whole idea is very well conceived. The OS, DSM, is great. They got tons of apps available everywhere. But to have decent performances, whether for video decoding or for generating photo galleries thumbnails, then you need a high-end model which comes with an Intel chip. Those are merely dual/quad core chips, but there's a huge difference compared to the ARM-based processor embedded in the low-end hardware. Also, that'll cost you around $700...without hard drives...

Now I know that there are some hacks which consist in installing DSM on a traditional PC. And I could probably do that on my MacBook Pro. But I guess I wanted to see what I could do myself first. If that setup fails in the long run, then I'll probably look around for this hack.

The Macserver hardware

So about 6 months ago I spilled my coffee on this 2012 MacBook Pro. The keyboard is acting up and the sound is gone. Of course, it was a drama. So I forgot about it and got a new one. A few days ago, I decided to give it another try so I just plugged a regular USB Mac keyboard. it works fine like that.  It's powered by a Core I7 with 4 GB of RAM and I had previously removed the sluggish 5400 RPM hard drive by a 256 GB SSD drive. Let's call it here the Macserver.

I plugged a regular 2.5" external drive which already contains lots of stuff in it like movies, photos albums or videos.

It sites on a USB tray which incorporates a fan to cool down the whole thing - not that it is hot at all but if it has to stay up forever then I'd rather help any heat dissipation. But in the end, I believe that I'll probably sleep the computer at night and have it up all day long, except when on holidays or out of town for a weekend ; it will stay up 24/24.

I installed Insomniax, a small freeware which prevents the laptop to go to sleep when the lid is closed.

It's connected to my fiber network via Wi-Fi but when we'll have finished re-arranging the office room then I'll plug it via Ethernet.

Managing media files: Plex server

What motivated me in the first place is that I got hold of a lifetime license of Plex, which precisely offers a software that turns your computer into a server. You can then stream your medias from any devices, as long as the Macserver is up and running. I simply tell Plex to look for specific folders in this external hard drive and it crawls them quite quickly.

My medias are then available from my two other MacBooks, the iPhone, and the iPad. It works both on the local network and outside. The good thing about Plex is that you can create user accounts with permissions which means that I can share my photo folder with someone and my movies with someone else

The other good thing about Plex is that there is a camera baclup feature. So all the iPhone photos are directly saved in a specific folder on the server and available everywhere..

File synchronization: BitTorrent Resilio Sync + Automator

Now one thing that I use a lot is file synchronization. I've tried all the popular ones and used Cloud Station on the Synology NAS. The idea is that the Macserver turns into a backup solution.

The good thing is that I can also have a backup of the synchronized files. So in case, the internal SSD get corrupted, I make use of this Automator script which creates a calendar event to perform a daily backup of the Resilio folders to an external hard drive.

I initially thought of ownCloud and quickly remembered all the bugs I encountered three years ago. Anyway, after installing MAMB to have a PHP server running, the ownCloud installer warned me that macOS is not part of the deal right now. So I promptly got rid of it.

I chose Resilio Sync - formerly known as Bittorrent Sync. I'm tempted to try SyncThings, but the project does not seem to be matured enough for me right now. But I'll definitely check it out.

Remotely downloading torrents: Transmission + Resilio

I did use Download Station quite a lot on the Synology. Well, I found a trick to replicate this... Resilio! Basically, I can have the Transmission Bittorrent client auto-process new torrent files found in a specific folder (in a Resilio sub-folder). I can also have it move the downloaded files to a particular folder.

So when away from home, I simply download a torrent, save it to a specific Resilio folder, and the Macserver does its job. The downloaded files is then directly placed into a folder which is processed by Plex. Perfect!

Remote desktop access: Back to My Mac + VNC

Whenever you setup an iCloud account, then you have the feature called Back to my Mac. In theory, it enables you to access all other Macs set up with this same iCloud account. It's also infamously known to be buggy. And it is.

Back to my Mac works great on the local network - after you've ticked all the boxes of the Sharing section in Preferences. I can view the content of the Macserver and easily start a screen sharing. It's directly built into the Finder.

But I just could not make it work outside the local network... So how do I do outside?

For my other MacBooks

For screen sharing, I realized that macOS has a built-in VNC service. All I have to do is open a browser window and type:

vnc://public-IP-address-of-the-Macserver

And that's all! I just log in my Macserver with the user session and I'm in.

For my iOS devices

To remotely access the Macserver desktop, I installed RealVNC and logged in successfully the same way. I don't even need to create an account.

From a Windows machine

So what I would really like is a Web Based VNC viewer working directly through the browser. The idea is to be able to remotely access the Macserver desktop from a cyber café.

I stumbled upon a couple of solutions that make use of HTML 5 to do this : NoVNC and Guacamole. I played a little bit with them but could not make them work...A bit too nerdy for me. I'm surprised not to have found a good and simple solution that works out-of-the-box

Then I decided to download and extract the content of three Chrome extensions. I tried to have the HTML files work inside a browser. The idea was that if it worked then I'd simply upload those files somewhere and use them as a Web app from any computer. But then, I wasn't lucky either...

I kind of gave up. But then i'd really love to have some sort of webased VNC solution on the client side. I thought this would be offered by Anydesk, Splashtop, Teamviewer & co... Instead I installed a portable version of RealVNC on a USB key attached to my keyring : old fashioned but more straightforward.

Update - July 2018

I finally found a great, fast, free, open source and very easy to use web VNC Solution. It comes from DWService, a one person project which I find absolutely stunning.

All you have to do is setup an account and install a small client (windows, MacOS, Linux...) on the server. From any HTML5 Web browser, you'll then be able to easily access the screen, but also all the files (including connected external hard drives). You will also be able to manage running processes. And you really have no set whatsiever to do.

Remote file access: Back to my Mac + SMB + WebDAVNav Server

For my other MacBooks

So I can access my Macserver files from the Finder via Back to my Mac on the local network. But what about outside the LAN?

This time I make use of the SMB protocol. Again, I fire up my browser and type in:

smb://public-IP-address-of-the-Macserver

And it works. Again, I just logged in with the user session and I'm in.

For my iOS devices

I installed the FileBrowser app. It's a paid app, probably $5, but kind of worth it. It analyses all available connected hardware on the same Wi-Fi network. The funny thing is that I can copy and paste files from one computer to another right from my phone or from my tablet!

But then what's the point of remote file access on the same network really ....?

Well, I can actually setup the Macserver public address and preset the login info. And boom! works fine - or shall I add: it works fine if you are outside the house network. So I actually have two connections set up in the app: one local and one external.

Now I wanted to find the easiest solution possible to access my files from a third-party computer. The idea was not to have to install anything like you wouldn't be able to do so on a cyber café. So I got interested in WebDAV.

I used to use WebDAV with the iDisk. I have horrible memories of a sluggish protocol working through the Finder. But it turns out it's pretty cool. I installed the free app WebDAVNav Server on the Mac Server. It's awesome and super simple to set up. Once running you can actually access your folders at :

http(s)://public-IP-address-of-the-Macserver:specificport

And because it's basically a dynamic page that helps you remotely browse your files, then you can actually customize the generated HTML and the CSS in the Mac Application folder

Handling dynamic DNS

One problem that I did not totally forsee was how to handle my server IP address. Since I set up the server, I changed my ISP. I believe that I do not have a fixed public IP anymore. My guess is that it changes every two months.

Of course, when it changes, it breaks every access outside the local network. Really not convenient when trying to sync files, or access the server. This unrealiability and unpredictability had me consider giving up the whole thing.

I decided to map the server public IP address to a specific domain and made use of this domain when setting up all devices for VNC, webDAV or SMB protocols. Whevever my IP would change, I'd only have to update it in my domain registrar settings. A 3-minute job. Much easier. Yet still I needed to find a way to be alerted of any change.

But then I learned the registrar update process can be done automatically with DynDNS. It requires a small piece of software on the server that automatically identifies the IP address and updates the registrar information on the fly. In my case I make use of dDNS Broker, which I believe I paid $5 on the Mac App Store.

Setting up a web server

At first I did not really intend to use my personal server as a web server. However, after finding a way to smoothly handle IP changes with a dynamic DNS solution, I decided to reconsider this option.

MacOS comes with Apache built-in. There is no more a visible option to activate it but it is here. There are a couple of command lines to write in the Terminal to manage it. But quite franckly, I can't be bothered to. I downloaded this free app called SimpleHTTPServer in the Mac App Store. It looks a lot like the webDAV tool that I use. All you have to do is tick the server on or off and choose a folder to share. That's it. By default you get a local address but all you have to do is to modify it with you IP address or, in my case, a domain name. Again, it looks like:

http(s)://public-IP-address-of-the-Macserver:specificport

Over there I host there the front page of my server with links to access it with various protocoles.

Simplified Access

So setting up the server is relatively easy but it involves several apps and the whole thing might appear a bit complex to someone who's not computer savvy.

To make things a bit easier I bought a domain name and mapped a few subdomains to the local and the external IP address, to Plex and to the WebDAV access.

I made a small webpage directly linking to SMB, VNC, WebDAV and Plex with either the local or the external IP address. Of course, the page is responsive and on the smartphone/tablet version, those links simply open four applications to access and manage the data on the Macserver.

I also made a small Chrome/Opera app for my wife so she can easily access those shortcuts.

So to sum up, right now I can:

  • Remotely access my media from a Mac or an iOS device
  • Auto-backup my phone camera roll on the server
  • Remotely access the Macserver desktop from a Mac or an iOS device
  • Remotely access the Macserver desktop from a Windows computer with a USB key
  • Remotely access the Macserver files from a Mac or an iOS device
  • Manage a file synchronization service
  • Auto-backup the synchronized files
  • Remotely access my files from any web browser
  • Host a website
  • Control the whole thing from a webpage or a Chrome extension
  • Garantee a smooth upstate with DynDNS

It's not perfect, actually having a laptop as a server is far from being perfect and it's probably the worst thing here. I have to pay attention to the Insomniax software and see if the laptop gets hot or not. But I guess it's not too bad for a couple days of tweaking things around. If that works well in the long run then I might consider a Hackintosh solution or a Mac Mini depending on the price/performance ratio.