Establish your own WebFTP-Server

Martin Zahn, Akadia AG, 17.03.2007
 

Overview

WebFTP offers a way of connecting to your FTP server, even when you are behind a firewall or proxy not allowing traffic to FTP Servers. This is very common in business networks. WebFTP overcomes this issue by making a FTP connection from your webserver to your FTP server and transfering the files from this web server to your webclient over the standard HTTP protocol.

Architecture


Needed Software

The installation and configuration of Apache / PHP is not explained in detail here, see original documentation:

Apache (2.0.54)

./configure --prefix=/usr/local/apache \
--enable-mods-shared=most \
--enable-ssl=shared \
--enable-mime-magic \
--enable-cern-meta \
--enable-proxy \
--enable-proxy-connect \
--enable-proxy-ftp \
--enable-proxy-http \
--enable-usertrack \
--enable-unique-id \
--enable-deflate

make
make install

PHP4 (4.3.10) for MySQL 4.1.12

./configure  --enable-ftp
             --with-apxs2=/usr/local/apache/bin/apxs
             --with-mysql=/usr/local/mysql
             --with-mysql-sock=/tmp/mysql.sock
make
make install
cp php.ini-dist /usr/local/lib/php.ini

It is important to enable FTP for PHP with the option --enable-ftp .

Edit your httpd.conf to load the PHP module. The path on the right hand side of the LoadModule statement must point to the path of the PHP module on your system. The make install from above may have already added this for you, but be sure to check.

LoadModule php4_module libexec/libphp4.so

Tell Apache to parse certain extensions as PHP.

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

Use your normal procedure for starting the Apache server:

/usr/local/apache/bin/httpd -k start -D SSL -D PHP4

ProFTPD (1.3.0a) - FTP-Server

Highly configurable GPL-licensed FTP server software, see INSTALL.

./configure --prefix=/usr/local/proftpd
make
make install

Edit:

/usr/local/etc/proftpd.conf

ServerName                      "FTP-Server Akadia AG"
ServerType                      standalone
DefaultServer                   on
Port                            21
Umask                           022
MaxInstances                    30
User                            nobody
Group                           nogroup
DefaultRoot                     ~
AllowOverwrite                  on

To cause every FTP user to be "jailed" (chrooted) into their home directory, uncomment the line DefaultRoot ~

net2ftp (net2ftp_v0.95.zip) - A web based FTP client

Installation procedure

  1. Unzip all the files on your computer, and upload them
    to your server.
     
  2. The /temp directory should be chmodded to 777.
     
  3. Set your settings in the settings.inc.php file

Details:

Important settings in settings.inc.php:

  • Enter an Admin panel password. If no password is entered, the Admin panel is not accessible.
     
  • Turn logging on or off (requires a MySQL database).
     
  • Choose if you want to set a daily consumption limit to restrict each user's daily data transfer volume and script execution time (requires a MySQL database). By default the data transfer volume is set to 50 MB per day and the script execution time to 1500 seconds per day - but this may be changed. Both figures are logged per IP address, and per FTP server. Once the daily consumption limit is reached, the user will still be able to browse FTP servers, but the transfer of data to/from the server will be blocked.

Set authorizations in settings_authorizations.inc.php:

  • Allow the users to connect to any FTP server, or only to a restricted list of FTP servers
     
  • Ban certain FTP servers
     
  • Ban certain IP addresses; users connecting from these addresses will not be able to use the website
     
  • Allow the users to connect to any FTP server port, or only to one port

To allow large file uploads and transfers, you may have to change these settings:

  • In the file php.ini: upload_max_filesize, post_max_size, max_execution_time, memory_limit
     
  • In the file php.conf: LimitRequestBody