Firewall Setup with UFW
- activate venv (
source MY_VENV_PATH/bin/activate
orworkon MY_VENV
) - UFW firewall
sudo apt install ufw
sudo vim /etc/default/ufw
, change IPV6=yes to IPV6=nosudo ufw allow OpenSSH
(the firewall will be blocking all connections accept SSH)sudo ufw enable
sudo ufw status
sudo ufw allow 8000
(create an exception for port 8000)
- run
python manage.py runserver 0.0.0.0:8000
to test it - in browser open http://SERVER_IP:8000/admin (there is no css yet, because of static files) - test gunicorn
gunicorn --bind 0.0.0.0:8000 MY_PROJECT.wsgi
- open in browser http://MY_DOMAIN:8000/admin (no css) - deactivate venv
deactivate
Resources:
➡️https://medium.com/@_christopher/deploying-my-django-app-to-a-real-server-part-i-de78962e95ac
➡️https://www.digitalocean.com/community/tutorials/initial-server-setup-with-debian-9