Some short instructions for the people struggling with the installation (debian/ubuntu) This will do a side wide installation of the dependencies, and we will use nginx to proxy our requests.
sudo apt-get install python3.4 python3-pip
git clone https://github.com/siacs/HttpUploadComponent httpupload
sudo mv httpupload /usr/local/share
cd /usr/local/share/httpupload
sudo pip3 install -r requirements.txt
cp config.example.yml config.yml
Open the config file with your favourite editor and change to your needs.
component_jid: upload.your.domain # the name of your component, must be unique.
component_secret: 1234 # the password that will authenticate the component against your xmpp server.
component_port: 5347 # leave the default.
storage_path : /var/lib/httpupload # make sure the user that will run this script has write permissions.
whitelist: # allow uploads for your domain only.
- your.domain
http_address: 127.0.0.1
http_port: 8080
get_url : https://upload.your.domain/get
put_url : https://upload.your.domain/put
After that create the required directory structure:
sudo mkdir /var/lib/httpupload
sudo chown www-data:www-data
You have to tell your xmpp server (in my case prosody) about the component. Open /etc/prosody/prosody.cfg.lua and add:
Component "upload.your.domain"
component_secret = "1234"
Component name and secret MUST match what you have inside your config.yml.
Restart prosody with sudo prosodyctl restart to enable the component.
At this point you should be able to start the server with:
./httpupload/server.py
Make sure the component authenticates against your xmpp server, it should look similar to this:
DEBUG Expire run finished in 0.000019s
DEBUG Loaded Plugin: XEP-0030: Service Discovery
DEBUG Loaded Plugin: upload files via http
DEBUG Connecting to localhost:5347
DEBUG DNS: Querying localhost for AAAA records.
DEBUG DNS: Error retreiving AAAA address info for localhost.
DEBUG DNS: Querying localhost for A records.
DEBUG Connecting to [::1]:5347
DEBUG Event triggered: connected
DEBUG ==== TRANSITION disconnected -> connected
DEBUG Starting HANDLER THREAD
Also check prosodys logfile:
cat /var/log/prosody/prosody.log
upload.your.domain:component info External component successfully authenticated
If everything works kill the server with CTRL+C.
We will use nginx to serve the files from get and use put to proxy our requests to httpuploadcomponent.
I assume you have nginx installed and have a valid certificate.
For recommended tls setting you can use mozillas tls config generator.
# serving the files
location /get {
alias /var/lib/httpupload;
}
# proxy put to the component
location /put {
limit_except GET {
proxy_pass http://[::]:8080;
}
proxy_set_header Host $host;
charset utf-8;
add_header X-Frame-Options DENY;
}
The startup scripts below are taken from the contrib directory and are slightly modified.
Create a new unit file:
sudo nano /lib/system/systemd/httpupload.service
[Unit]
Description=XMPP component for HTTP file uploads
After=network.target
[Service]
type=simple
User=www-data
Group=www-data
ExecStart=/usr/bin/python3 /usr/local/src/httpupload/httpupload/server.py --config /usr/local/src/httpupload/httpupload/config.yml
[Install]
WantedBy=multi-user.target
Enable and start the unit:
sudo systemctl enable httpupload.service
sudo systemctl start httpupload.service
Create the sysvinit file:
sudo nano /etc/init.d/httpupload
#!/bin/bash
### BEGIN INIT INFO
# Provides: HttpUploadComponent
# Required-Start: prosody
# Required-Stop: prosody
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start HttpUploadComponent
# Description: HttpUploadComponent for prosody
### END INIT INFO
## more info: http://wiki.debian.org/LSBInitScripts
. /lib/lsb/init-functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/usr/local/src/httpupload/httpupload/server.py
NAME=httpuploadcomponent
DESC=HttpUploadComponent
CONFIG=/usr/local/src/httpupload/httpupload/config.yml
LOGFILE=/var/log/nginx/httpuploadcomponent.log
PIDFILE=/var/run/${NAME}.pid
USER=www-data
# Allow user to override default values listed above
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
export LOGNAME=$USER
test -x $DAEMON || exit 0
set -e
function _start() {
start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE
}
function _stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3
rm -f $PIDFILE
}
function _status() {
start-stop-daemon --status --quiet --pidfile $PIDFILE
return $?
}
case "$1" in
start)
echo -n "Starting $DESC: "
_start
echo "ok"
;;
stop)
echo -n "Stopping $DESC: "
_stop
echo "ok"
;;
restart|force-reload)
echo -n "Restarting $DESC: "
_stop
sleep 1
_start
echo "ok"
;;
status)
echo -n "Status of $DESC: "
_status && echo "running" || echo "stopped"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0
Enable and start the sysvinit script:
sudo chmod +x etc/init.d/httpupload
sudo update-rc.d httpupload defaults
sudo service httpupload start
If you have problems with the instructions above you might want to check out prosodys mod_http_upload which provides most of the functionality of httpuploadcomponent but should be easier to install.