How can I build my own Android app store server?
Requirements:

 1. Has to be accessible through the Internet, not just internal
    corporate networks (i.e. must have a front end interface)
 2. App Store server has to be hosted internally (i.e. no third-party hosting services)
 3. Preferably securable by username/password
 4. Preferably able to automatically push updates to authorized devices

The reasoning behind this is that we want to do a limited beta of our app to about 1,000 users, and we need a way to distribute updates to those users' devices without making our beta software accessible to the general public.

We initially explored simply hosting the APKs on an Apache web server, but since we wanted to limit access, we tried putting a username/password on the web server. Well, it turns out that the Android download manager has a bug that prevents downloading files to the phone if it's protected by htaccess.

Next we thought of using an FTP server and then just installing an FTP client on each beta tester's device, but that's pretty janky. This is now our final option.

An "internal" app store server seems to be the best bet. Is there a solution out there for this? Preferably a free/open source one, if that's possible.
How can I build my own Android app store server?
===

Requirements:

 1. Has to be accessible through the Internet, not just internal
    corporate networks (i.e. must have a front end interface)
 2. App Store server has to be hosted internally (i.e. no third-party hosting services)
 3. Preferably securable by username/password
 4. Preferably able to automatically push updates to authorized devices

The reasoning behind this is that we want to do a limited beta of our app to about 1,000 users, and we need a way to distribute updates to those users' devices without making our beta software accessible to the general public.

We initially explored simply hosting the APKs on an Apache web server, but since we wanted to limit access, we tried putting a username/password on the web server. Well, it turns out that the Android download manager has a bug that prevents downloading files to the phone if it's protected by htaccess.

Next we thought of using an FTP server and then just installing an FTP client on each beta tester's device, but that's pretty janky. This is now our final option.

An "internal" app store server seems to be the best bet. Is there a solution out there for this? Preferably a free/open source one, if that's possible.