La version Française est disponible ici: Installer son propre serveur Firefox sync avec PHP-FPM et Nginx
Mozilla foundation offers synchronisation facilities, so that you can get back you browser environment when you work on another desktop. If you can just use Mozilla's storage infrastructure, you also have the choice to build your own.
The most paranoid of us will see the opportunity to get rid of Mozilla foundation for that purpose and ensure that Mozilla won't ever have the opportunity to get into their privacy. Personnaly, I don't believe that could happen: this is not the way Mozilla wants to spread the web and all informations you send to them are encrypted.
But deploying and maintaining an IT infrastructure to support Sync facilities cost money, a lot of... Installing your own Sync server makes Mozilla save some. Not a lot of course, but if millions of Firefox users install their own Sync server, Mozilla could save a lot of money.
Finally, as I operate my own web server, my own mail server, my own jabber server, and so on..., and since I like discovering new things, I decided to install my own Sync server. A matter of independance :)
Here we are. So, I want to setup my own Firefox Sync server onto my Nginx and PHP-FPM stack.
Base setup is described here:
- Nginx: automatic vhosts configuration with subdomains, SSL and authentication support - second version
- PHP-FPM, application server made by PHP
Based on the configuration describe above, we have to setup an "application pool". That means that Firefox Sync server will be available for different domains and, of course, for many users.
Lets create directories tree:
Once done, we can configure PHP-FPM:
Yes, you read it, Firefox Sync minimal server can run in chroot. Happy :)
Firefox Sync minimal server needs SQlite support in PHP. Lets install it:
Here we are with PHP. It's now time to configure NGinx. README file suggest to use an Alias, with Apache. Since we use NGinx, we can't do this way. In fact, It's just about making sure that every request will be rewritted to use index.php with PATH_INFO variable setted. Here's what you can do with NGinx:
fastcgi_split_path_info directive. In official NGinx documentation, used regex is
^(.+\.php)(.*)$. Unfortunatly, Firefox Sync client performs a request like
/1.0/user/username/info/collections?v=1.6.2. With regex from documentation, the query string
?v=1.6.2 is included in
PATH_INFO declaration, which makes first connection failed. Even if further synchronisations will complete, you won't be able, as an example, to see tabs from other computers. Bad, isn't it ? :-/
^(.+\.php)([^?]*).*$; solves the problem.
Now, you juste have to include this configuration file into the vhost one, like:
Firefox Sync minimal server installation
Now, you just have to install PHP code. Nothing difficult here:
Last command is important since SQlite DB will be written is root directory. Therefore, the user
fsync needs write grants.
DB creation will be made upon first connection. Just use your favorite brower (who say Chrome O_o ?) and point it to
//fsync.domain.tld/1.0/blah/info/collection using login
blah and password
garbage. Authentication will fail but DB should be now created.
Last step, populate you DB with users:
Now you can configure you Sync account on you browser. Don't forget to use
Custom Sync server to point you own one. It seems that Modification of an existing account is not enough, so I suggest you to delete it and create a completely new one.
Have fun !
Sources and references
- Firefox Sync
- Minimal server