I was asked yesterday by a colleague for ideas on how to allow FileMaker server to manage content which could be shared publicly using its built-in web server.
We chatted about the possibility of writing content into the web root folder, but that would have meant using a plugin and being confronted with security issues because of the way in which FileMaker has limited access to folders – on the server it’s limited to the Documents and Scripts folders.
On Windows FileMaker server configures IIS while on macOS it installs an instance of the httpd web server. Both of these have the ability to create ‘virtual’ content folders. Thus if we configure the web server to have a virtual folder which exists inside the FileMaker server Documents folder we can solve this problem without permissions issues and regular FileMaker script steps can create sub folders, export container content, write files etc which become immediately web accessible.
As a side note – if you decided to head down this route, remember that everything which is in such a folder is available to everyone – no authentication, no access control, just sitting out there in a public web folder. In this specific situation that was exactly what was wanted, but that may not always be the case.
We also considered using the Data API, but that would have meant everything had to be in containers which may not always be appropriate, and also comes with the issue of authentication!
Adding a virtual folder
To get this up and running on a Windows FileMaker server takes a few steps.
- Create the folder you want to use in the FileMaker Server Documents folder, by default that's at
C:\Program Files\FileMaker\FileMaker Server\Data\Documents. In this case I've called it 'Downloads' since that describes its purpose quite well.
- Next we need to launch 'Internet Information Services (IIS) Manager' - you can find this under Administrative Tools. Once it opens, expand the computer name on the left, then sites, and you're looking for the site called
FMWebSite. If you've followed FileMaker best practice that should be the only site running on that server, which isn't quite how things are on this development server of mine!
- Right-click on this server, and select 'Add Virtual Directory'
- In the resulting dialog, give the virtual directory an alias - I'd suggest this should match what you called the folder, so I named this 'downloads'. Use the triple dots to the right of the Physical path field and navigate to the folder you created.
- Ok, that dialog out of the way, and you're done! You should now see the new virtual directory listed and you can access the content using
https://your.fms-server.com/downloads/the-file-in-there.txt. If you select the folder in IIS, then the Content View from the bottom of the IIS manager you can see the files which are contained in there.
There's no GUI to manage the instance of httpd which FileMaker server installs but we don't actually need one because the process is somewhat simpler in the macOS world.
- Begin by navigating to the FileMaker server Documents folder. In a finder window CMD-Shift-G to 'go to a folder'. By default the path is
/Library/FileMaker Server/Data/Documents. Right click, New Folder, and add your folder. I've called this
Downloads since it matches the purpose we're trying to achieve.
- Now we need to open a terminal and create something called a symlink, or symbolic link, to the correct location. You can find Terminal under Applications > Utilities. Enter each of these commands
cd /Library/FileMaker\ Server/HTTPServer/htdocs/httpsRoot
ln -s ../../../Data/Documents/Downloads/ ./downloads
sudo chown fmserver:fmsadmin ./downloads
By way of explanation
- change directory to the https document root for the web server
- create a symlink which links to the Downloads folder we created above, and call it 'downloads' locally. You'll want to adjust those names to suit your use-case
- ensure that symlink is owned by the correct user - you will be asked to provide your password at this point
- Back to finder, we now need to modify the httpd.conf file. Navigate to
/Library/FileMaker Server/HTTPServer/conf/extra right click on
httpd-ssl.conf and select Open With > TextEdit
- On line 81 you will find
# General setup for the virtual host
ErrorLog "||/usr/sbin/rotatelogs '/Library/FileMaker Server/HTTPServer/logs/ssl_error_log' 10M"
TransferLog "||/usr/sbin/rotatelogs '/Library/FileMaker Server/HTTPServer/logs/ssl_access_log' 10M"
Immediately after that add the following
This allows httpd to follow any symlinks which you place into the httpsRoot folder, which is exactly what we just did above.
- Finally back to Terminal and we need to restart the FileMaker instance of httpd, this can be achieved with.
sudo /Library/FileMaker\ Server/HTTPServer/bin/httpdctl graceful
Again, you may be asked for your password to complete this.
- That's it - try it out by dropping a file into the Downloads folder which you can then access via
Try it out
There’s a version of this currently running on our FMS which you can try out (assuming you’ve got FileMaker client installed). The version on the server is locked down, however you can also download a copy to see how we’re dealing with container export on server (which isn’t generally supported, but can be achieved using the FMS 18 File handling functions).