Uncategorized

Adding MIME Types To Support App Distribution On Apache, IIS, and NGINX

iOS Apps are .ipa files, which are compiled bundles of files that comprise an App on a device. By default, most web servers do have a handler that tells them what to do in the event that a call attempts to access one of these files. Therefore, in order to support downloading those files properly, you need to teach the server how to handle them.

First, let’s grab the MIME type from the Mac file command. To do so, run file with the, big surprise, –mime-type option and then the path to the file:

file --mime-type /Users/ce/Downloads/enrollmentProfile.mobileconfig

The output would be as follows, indicating that a file with the .mobileconfig extension has the application/octet-stream extension:

/Users/ce/Downloads/enrollmentProfile.mobileconfig: application/octet-stream

Since more and more apps are deep linking a plist into the app, we’ll also add a plist. The output on a Mac for the various file types is:

  • .mobileconfig: text/xml or application/octet-stream if signed
  • .mobileprovisioning: text/xml or application/octet-stream if signed
  • .ipa: application/x-ios-app
  • .plist: text/xml or application/octet-stream if a binary plist

In the above, note that a signed mobileconfig, a signed mobile provisioning, and a binary plist are basically interpreted as binary files. This means that when possible, use signed mobileconfig and mobileprovisioning files so you have a consistent handler.

We’ll start defining those with Apache. Handlers are managed in Apache’s global configuration file, often located at /etc/httpd.d/httpd.conf and you would paste the following towards the bottom of the file where you see the media types (note that each AddType is teaching the web server what type of file each file extension indicates):

AddType application/octet-stream .ipa
AddType text/plain .plist
AddType aapplication/octet-stream .mobileconfig

In the above example we set a plist to plain in order to show that, well, sometimes it is. Alternatively (or additively if you need to host both binary and flat plist files), you could create an .htaccess file in the directory with the files (e.g. if you don’t have root access to change the httpd.conf), by adding something similar (the # is indicating a commented line):

# Apps
AddType application/octet-stream .ipa
AddType application/octet-stream .plist
AddType application/octet-stream .mobileconfig

For IIS, go into IIS Manager and right-click on the name of the server, select Properties and click on New… in order to create new MIME types. Then add each using the above types.

To update on nginx, edit the mime.types file in the conf directory for nginx. This is often found in /etc/nginx or /opt/nginx but ymmv. Once found, in mime.types look for a types section wrapped in curly-braces {}:

types { application/octet-stream mobileprovision; application/octet-stream mobileconfig; application/octet-stream plist; application/octet-stream ipa; }

Note: In some cases you might find that “application/x-apple-aspen-config” and in others text/plain or text/xml works better for .mobileconfig MIME types.

If you have failures, you can use a proxy to check it. Here, you’d probably want to use a unique port number to make calls easier to use. If you use Charles Proxy, you’d configure the proxy in the Wifi settings of an iOS device and then open the link in a browser and watch for any failures.