initial
This commit is contained in:
43
src/deploy.sh
Executable file
43
src/deploy.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Django Proxmox Mikrotik Deploy Script
|
||||
set -e
|
||||
|
||||
PROJECT_PATH="/usr/share/django-proxmox-mikrotik"
|
||||
VENV_PATH="$PROJECT_PATH/venv"
|
||||
|
||||
echo "Starting Django Proxmox Mikrotik deployment..."
|
||||
|
||||
# Activate virtual environment
|
||||
source $VENV_PATH/bin/activate
|
||||
|
||||
# Change to project directory
|
||||
cd $PROJECT_PATH
|
||||
|
||||
# Install/update dependencies
|
||||
echo "Installing dependencies..."
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Run database migrations
|
||||
echo "Running database migrations..."
|
||||
python manage.py migrate
|
||||
|
||||
# Collect static files
|
||||
echo "Collecting static files..."
|
||||
python manage.py collectstatic --noinput
|
||||
|
||||
# Create static directory if it doesn't exist
|
||||
mkdir -p /usr/share/django-proxmox-mikrotik/static
|
||||
|
||||
# Set proper permissions
|
||||
echo "Setting permissions..."
|
||||
chown -R www-data:www-data $PROJECT_PATH
|
||||
chmod -R 755 $PROJECT_PATH
|
||||
|
||||
# Restart services
|
||||
echo "Restarting services..."
|
||||
systemctl restart django-proxmox-mikrotik
|
||||
systemctl restart nginx
|
||||
|
||||
|
||||
echo "Deployment completed successfully!"
|
||||
77
src/etc/nginx/sites-available/django-proxmox-mikrotik
Normal file
77
src/etc/nginx/sites-available/django-proxmox-mikrotik
Normal file
@@ -0,0 +1,77 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# Static files
|
||||
location /static/ {
|
||||
alias /usr/share/django-proxmox-mikrotik/static/;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Media files
|
||||
location /media/ {
|
||||
alias /usr/share/django-proxmox-mikrotik/media/;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# API endpoints for live status updates
|
||||
location /manager/task/ {
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Extended timeouts for long-running tasks
|
||||
proxy_connect_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
proxy_read_timeout 600s;
|
||||
|
||||
# Disable caching for API responses
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
}
|
||||
|
||||
# AJAX endpoints
|
||||
location /frontend/ {
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Standard timeouts for API calls
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
|
||||
# Disable caching for API responses
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
# Main application
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Timeout settings
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# Logs
|
||||
access_log /var/log/nginx/django-proxmox-mikrotik_access.log;
|
||||
error_log /var/log/nginx/django-proxmox-mikrotik_error.log;
|
||||
}
|
||||
17
src/etc/systemd/system/django-proxmox-mikrotik.service
Normal file
17
src/etc/systemd/system/django-proxmox-mikrotik.service
Normal file
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Django Proxmox Mikrotik Application
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=www-data
|
||||
Group=www-data
|
||||
WorkingDirectory=/usr/share/django-proxmox-mikrotik
|
||||
ExecStart=/usr/share/django-proxmox-mikrotik/venv/bin/python manage.py runserver 0.0.0.0:8000
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user