Camera proxy backend with Google OAuth2 authentication. It is intended to be run on a VM or container (e.g. LXC).
Development uses self-hosted servers for the Flask backend and the React frontend.
cd flask-backend
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
cd flask-backend
. .venv/bin/activate
python3 app.py
sudo apt install npm
cd react-frontend
npm install
cd react-frontend
npm start
Make sure you have exited the development venv before starting a production installation.
sudo apt install git apache2 libapache2-mod-wsgi-py3 python3-flask python3-pip python3.10-venv
You will need your github ssh keys configured before this will work.
git clone [email protected]:/makeitlabs/camproxy camproxy-ng
sudo cp -R camproxy-ng /var/www
sudo chown -R username:www-data /var/www/camproxy-ng
(replace username with your username)
python3 -m venv /var/www/camproxy-ng/flask-backend/.venv
. /var/www/camproxy-ng/.venv/bin/activate
You must have activated the venv per above, otherwise these will not install in the correct place.
cd /var/www/camproxy-ng/flask-backend
pip install -r requirements.txt
The backend uses mod-wsgi and points to the python3 virtual environment you set up above.
The frontend points to the built version of the React frontend.
sudo cp /var/www/camproxy-ng/apache2/camproxy-frontend.conf /etc/apache2/sites-available
sudo cp /var/www/camproxy-ng/apache2/camproxy-backend.conf /etc/apache2/sites-available`
[create/copy self-signed SSL certs to the /etc/ssl dir]
sudo a2ensite camproxy-frontend
sudo a2ensite camproxy-backend
sudo a2enmod ssl
Copy env-example
to .env
and configure it as needed. You will need credentials for the nxwitness server to pull images via the API.
Go here and set up a new OAuth2 client ID - https://console.cloud.google.com/apis/credentials
The client must have an Authorized Redirect URL, e.g.: https://cameras.makeitlabs.com/api/callback
Download and copy the client secret json file to /var/www/camproxy-ng/flask-backend/conf/client_secret.json
(look for "Download JSON" from the Google Cloud admin page for the client ID)
The application is provided publically via an nginx proxy in production. Set up a LetsEncrypt cert for the domain, e.g. cameras.makeitlabs.com
and enable force SSL.
- Forward https for / to the camproxy frontend at port 443.
- Set up a Custom Location for
/api/
and point it toproduction-host/
port 8443. Note the slashes are important in the nginx config. - Use the SSL cert you acquired for the domain earlier.
sudo apachectl restart
Production logs appear in:
- Backend:
/var/log/apache2/camproxy-backend.log
- Frontend:
/var/log/apache2/camproxy-frontend.log