-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from alegarsan11/develop
Deployment on bastion
- Loading branch information
Showing
8 changed files
with
106 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,37 @@ | ||
#! /bin/bash | ||
#!/bin/bash | ||
|
||
sudo git clone https://github.com/alegarsan11/nftables-gui.git /var/www/flask | ||
# Configuración de Matplotlib | ||
export MPLCONFIGDIR=/tmp/matplotlib | ||
sudo mkdir -p $MPLCONFIGDIR | ||
sudo chown www-data:www-data $MPLCONFIGDIR | ||
sudo chmod 777 $MPLCONFIGDIR | ||
|
||
# Variables | ||
PROJECT_DIR=/var/www/flask/nftables-frontend | ||
PROJECT_NAME=nftables-gui | ||
WSGI_FILE=wsgi.py | ||
VENV_DIR=$PROJECT_DIR/venv | ||
PYTHON_VERSION=python3.8 | ||
# Instalación de dependencias | ||
sudo apt-get install -y libfreetype6-dev libxft-dev | ||
|
||
# Actualizar los repositorios de paquetes | ||
sudo apt update | ||
# Copiar la aplicación | ||
sudo cp -r nftables-frontend /usr/share | ||
|
||
# Instalar Apache y el módulo mod_wsgi para Python 3 si no están instalados | ||
sudo apt install -y apache2 libapache2-mod-wsgi-py3 | ||
|
||
# Crear un archivo WSGI para que Apache pueda interactuar con la aplicación Flask | ||
cat <<EOT > $PROJECT_DIR/$WSGI_FILE | ||
import sys | ||
import logging | ||
# Configurar el logging | ||
logging.basicConfig(stream=sys.stderr) | ||
# Añadir el directorio del proyecto al path | ||
sys.path.insert(0, "$PROJECT_DIR") | ||
from app import app as application # Ajusta según tu archivo principal de Flask | ||
EOT | ||
|
||
# Configurar Apache para servir la aplicación Flask | ||
sudo tee /etc/apache2/sites-available/$PROJECT_NAME.conf > /dev/null <<EOT | ||
<VirtualHost *:80> | ||
ServerName localhost | ||
WSGIDaemonProcess $PROJECT_NAME python-path=$VENV_DIR/lib/$PYTHON_VERSION/site-packages | ||
WSGIScriptAlias / $PROJECT_DIR/$WSGI_FILE | ||
<Directory $PROJECT_DIR> | ||
Require all granted | ||
</Directory> | ||
Alias /static $PROJECT_DIR/static | ||
<Directory $PROJECT_DIR/static/> | ||
Require all granted | ||
</Directory> | ||
ErrorLog \${APACHE_LOG_DIR}/$PROJECT_NAME_error.log | ||
CustomLog \${APACHE_LOG_DIR}/$PROJECT_NAME_access.log combined | ||
</VirtualHost> | ||
EOT | ||
# Instalación y configuración de Apache con WSGI | ||
sudo apt-get install -y libapache2-mod-wsgi-py3 | ||
sudo a2enmod wsgi | ||
|
||
# Actualizar los repositorios de paquetes | ||
sudo apt update | ||
# Configuración del sitio de Apache | ||
sudo cp nftables-frontend/nftables-config.conf /etc/apache2/sites-available/nftables-config.conf | ||
sudo a2ensite nftables-config.conf | ||
|
||
# Instalar Apache y el módulo mod_wsgi para Python 3 si no están instalados | ||
sudo apt install -y apache2 libapache2-mod-wsgi-py3 | ||
# Ajuste de permisos | ||
sudo chmod 664 /usr/share/nftables-frontend/instance/nftables.db | ||
sudo chown www-data:www-data /usr/share/nftables-frontend/instance/nftables.db | ||
sudo chown -R www-data:www-data /usr/share/nftables-frontend | ||
sudo chmod -R 775 /usr/share/nftables-frontend | ||
sudo chmod -R 775 /usr/share/nftables-frontend/instance | ||
sudo chmod -R 775 /usr/share/nftables-frontend/static | ||
sudo chown -R www-data:www-data /usr/share/nftables-frontend/static | ||
|
||
# Habilitar el sitio y el módulo wsgi | ||
sudo a2ensite $PROJECT_NAME.conf | ||
sudo a2enmod wsgi | ||
#Reiniciar Apache para aplicar los cambios | ||
# Reiniciar Apache | ||
sudo systemctl restart apache2 | ||
|
||
echo "La aplicación Flask ahora debería estar disponible en http://localhost" | ||
# Iniciar el parser de nftables | ||
cd nftables-parser | ||
sudo hug -f main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<VirtualHost *:80> | ||
ServerName www.example.com | ||
ServerAlias example.com | ||
DocumentRoot /usr/share/nftables-frontend | ||
WSGIDaemonProcess nftables-frontend user=www-data group=www-data threads=5 | ||
WSGIScriptAlias / /usr/share/nftables-frontend/run.wsgi | ||
<Directory /usr/share/nftables-frontend> | ||
WSGIProcessGroup nftables-frontend | ||
WSGIApplicationGroup %{GLOBAL} | ||
Options Indexes FollowSymLinks MultiViews | ||
AllowOverride All | ||
Require all granted | ||
</Directory> | ||
Alias /static /usr/share/nftables-frontend/static | ||
<Directory /usr/share/nftables-frontend/static> | ||
Require all granted | ||
</Directory> | ||
Alias /templates /usr/share/nftables-frontend/templates | ||
<Directory /usr/share/nftables-frontend/templates> | ||
Require all granted | ||
</Directory> | ||
ErrorLog ${APACHE_LOG_DIR}/error.log | ||
CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import os | ||
import sys | ||
import matplotlib | ||
matplotlib.use('Agg') # Configurar el backend de Matplotlib | ||
|
||
# Establece la variable de entorno MPLCONFIGDIR | ||
os.environ['MPLCONFIGDIR'] = '/tmp/matplotlib' | ||
|
||
# Añade tu aplicación al path de Python | ||
sys.path.insert(0,'/usr/share/nftables-frontend') | ||
|
||
# Importa tu aplicación | ||
from app import app as application |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters