# Project Structure server.py # the main flask server app.py # the flask app wrapper that can be started via wsgi scripts/ # user add/deletion scripts used for user management static/ # static files of the flask web-server (js/css etc.) templates/ # jinja html templates used by the web-server (the actual web-pages) setup.sh # remote setup script aws/ # aws templates/files flask-ftp.service # the systemd service used to start the webserver (change port and interface here) # Local Requirements ## setup.sh - ssh - rsync # Remote Requirements ## Packages (APT) - vsftpd - python3 - pip ## Python Requirements - flask - flask-sqlalchemy - waitress ## Setup-Script ./setup.sh TARGET_IP_OR_DNS The start script (*setup.sh*) performs the following task in this order: - run apt update and install relevant packages (CMD\_APT) - install the python packages via the python package manager pip (CMD\_PIP) - add a user for flask to run as (CMD\_FLASK\_USER) - add sudoers lines to allow flask user to add and delete users (CMD\_SUDOERS\_ADD/DEL) - transfer the web-server files (rsync) - change FTP configuration to allow writes (CMD\_SET\_FTP\_WRITE\_YES) - restart the FTP to apply the new configuration server (CMD\_RESTART\_FTP) - lock out any ssh but root just to be safe (CMD\_LOCK\_SSH) # AWS The AWS-template setup uses git instead of rsync to pull the server files. The ssh-key fingerprint must be verified in advanced. - create a key-pair called *"flask-ftp"* or change the value of *"KeyName"* in *aws/template.yml* to an existing key pair (see "AWS Network & Security -> Key Pairs" for details) - create a new stack (CloudFormation -> Stacks -> Create Stack) and upload the template (*aws/template.yml*) - go to Instances, select Security and click the security group, add inbound for the ports you want to use (e.g. FTP Ports, 80, 443 or 5000, allowing all for simplicity, is reasonably safe too in this case, since there's nothing running on the server except the public services) # Chaning port or interface The service is deployed via *"waitress"* and the startup command is defined in the *"ExecStart"*, including interface and port. You can swap out waitress for any other wsgi-server like *uwsgi* or *gunicorn*. # Changing the Repository The AWS-Setup currently uses *git@github.com:FAUSheppy/jeffrey_miller_flask_ftp.git* as the repository to pull and adds a deploy key configured in this repository. If you change the repository, you need to configure a new deploy key and change the repository URL in *aws/template.yml*.