Update README.md
This commit is contained in:
parent
0e3924de81
commit
b0514173f3
279
README.md
279
README.md
@ -1,7 +1,8 @@
|
||||
# Apache-Proxy-Manager
|
||||
|
||||
Struttura
|
||||
## 1. Struttura del Progetto
|
||||
|
||||
```
|
||||
proxy-manager/
|
||||
├── backend/
|
||||
│ ├── app/
|
||||
@ -23,4 +24,280 @@ proxy-manager/
|
||||
│ ├── package.json
|
||||
│ └── vite.config.ts
|
||||
└── docker-compose.yml
|
||||
```
|
||||
|
||||
## 2. Backend - Nuovi File Necessari
|
||||
|
||||
### config.py
|
||||
```python
|
||||
import os
|
||||
from datetime import timedelta
|
||||
|
||||
class Config:
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(24)
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
||||
'postgresql://postgres:postgres@localhost/proxy_manager'
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
||||
# JWT Settings
|
||||
JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY') or os.urandom(24)
|
||||
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
|
||||
|
||||
# SSL Settings
|
||||
SSL_CERT_DIR = os.environ.get('CERT_DIR') or '/opt/proxy-manager/certs'
|
||||
SSL_KEY_DIR = os.environ.get('KEY_DIR') or '/opt/proxy-manager/keys'
|
||||
|
||||
# Proxy Settings
|
||||
PROXY_CHECK_INTERVAL = 60 # seconds
|
||||
STATS_COLLECTION_INTERVAL = 300 # seconds
|
||||
```
|
||||
|
||||
### requirements.txt
|
||||
```
|
||||
Flask==2.3.3
|
||||
Flask-SQLAlchemy==3.1.1
|
||||
Flask-Login==0.6.2
|
||||
Flask-JWT-Extended==4.5.2
|
||||
Flask-Cors==4.0.0
|
||||
psycopg2-binary==2.9.9
|
||||
python-dotenv==1.0.0
|
||||
schedule==1.2.0
|
||||
pyOpenSSL==23.2.0
|
||||
gunicorn==21.2.0
|
||||
certbot==2.7.4
|
||||
```
|
||||
|
||||
## 3. Frontend - Nuovi File Necessari
|
||||
|
||||
### src/services/api.ts
|
||||
```typescript
|
||||
import axios from 'axios';
|
||||
|
||||
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:5000';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: API_URL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
// Add token to requests
|
||||
api.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
|
||||
export const auth = {
|
||||
login: (username: string, password: string) =>
|
||||
api.post('/auth/login', { username, password }),
|
||||
logout: () => api.post('/auth/logout')
|
||||
};
|
||||
|
||||
export const proxies = {
|
||||
getAll: () => api.get('/api/proxy'),
|
||||
create: (data: any) => api.post('/api/proxy', data),
|
||||
update: (id: number, data: any) => api.put(`/api/proxy/${id}`, data),
|
||||
delete: (id: number) => api.delete(`/api/proxy/${id}`),
|
||||
getHealth: (id: number) => api.get(`/api/proxy/${id}/health`)
|
||||
};
|
||||
|
||||
export const stats = {
|
||||
getTraffic: (days: number = 7) =>
|
||||
api.get('/api/access-logs', { params: { days } })
|
||||
};
|
||||
|
||||
export default api;
|
||||
```
|
||||
|
||||
### package.json
|
||||
```json
|
||||
{
|
||||
"name": "proxy-manager-frontend",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.6.2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"recharts": "^2.10.3",
|
||||
"lucide-react": "^0.263.1",
|
||||
"tailwindcss": "^3.3.0",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^4.2.0",
|
||||
"typescript": "^5.0.0",
|
||||
"vite": "^5.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4. Docker Setup
|
||||
|
||||
### docker-compose.yml
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
backend:
|
||||
build: ./backend
|
||||
ports:
|
||||
- "5000:5000"
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://postgres:postgres@db/proxy_manager
|
||||
- SECRET_KEY=your-secret-key-here
|
||||
- JWT_SECRET_KEY=your-jwt-secret-here
|
||||
volumes:
|
||||
- ./certs:/opt/proxy-manager/certs
|
||||
- ./keys:/opt/proxy-manager/keys
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
frontend:
|
||||
build: ./frontend
|
||||
ports:
|
||||
- "3000:80"
|
||||
environment:
|
||||
- VITE_API_URL=http://localhost:5000
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
db:
|
||||
image: postgres:15
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DB=proxy_manager
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
```
|
||||
|
||||
## 5. Guida all'Installazione e Avvio
|
||||
|
||||
### Prerequisiti
|
||||
- Docker e Docker Compose
|
||||
- Node.js 18+ (per sviluppo locale)
|
||||
- Python 3.9+ (per sviluppo locale)
|
||||
- PostgreSQL (per sviluppo locale)
|
||||
|
||||
### Sviluppo Locale
|
||||
|
||||
1. **Setup Backend**
|
||||
```bash
|
||||
# Create virtual environment
|
||||
python -m venv venv
|
||||
source venv/bin/activate # Linux/Mac
|
||||
# o
|
||||
.\venv\Scripts\activate # Windows
|
||||
|
||||
# Install dependencies
|
||||
cd backend
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Set environment variables
|
||||
export FLASK_APP=wsgi.py
|
||||
export FLASK_ENV=development
|
||||
export DATABASE_URL=postgresql://postgres:postgres@localhost/proxy_manager
|
||||
|
||||
# Initialize database
|
||||
flask db upgrade
|
||||
|
||||
# Run backend
|
||||
flask run
|
||||
```
|
||||
|
||||
2. **Setup Frontend**
|
||||
```bash
|
||||
cd frontend
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Utilizzo con Docker
|
||||
|
||||
1. **Preparazione**
|
||||
```bash
|
||||
# Create necessary directories
|
||||
mkdir -p certs keys
|
||||
|
||||
# Copy environment files
|
||||
cp backend/.env.example backend/.env
|
||||
cp frontend/.env.example frontend/.env
|
||||
```
|
||||
|
||||
2. **Avvio**
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
3. **Accesso**
|
||||
- Frontend: http://localhost:3000
|
||||
- Backend API: http://localhost:5000
|
||||
|
||||
4. **Account Default**
|
||||
```
|
||||
Username: admin
|
||||
Password: admin123
|
||||
```
|
||||
|
||||
## 6. Funzionalità Principali
|
||||
|
||||
1. **Gestione Proxy**
|
||||
- Creazione e gestione di proxy inversi
|
||||
- Monitoraggio dello stato in tempo reale
|
||||
- Statistiche di traffico
|
||||
|
||||
2. **Gestione SSL**
|
||||
- Generazione automatica certificati SSL
|
||||
- Rinnovo automatico Let's Encrypt
|
||||
- Monitoraggio scadenze
|
||||
|
||||
3. **Monitoraggio**
|
||||
- Dashboard in tempo reale
|
||||
- Grafici di traffico
|
||||
- Logs di accesso
|
||||
|
||||
4. **Gestione Utenti**
|
||||
- Autenticazione JWT
|
||||
- Gestione ruoli (admin/user)
|
||||
- Audit logging
|
||||
|
||||
## 7. Note di Sicurezza
|
||||
|
||||
1. Cambiare immediatamente le password default
|
||||
2. Utilizzare chiavi segrete sicure in produzione
|
||||
3. Configurare correttamente i permessi delle directory dei certificati
|
||||
4. Abilitare HTTPS in produzione
|
||||
5. Configurare correttamente CORS in produzione
|
||||
|
||||
## 8. Manutenzione
|
||||
|
||||
1. **Backup Database**
|
||||
```bash
|
||||
docker-compose exec db pg_dump -U postgres proxy_manager > backup.sql
|
||||
```
|
||||
|
||||
2. **Aggiornamento**
|
||||
```bash
|
||||
docker-compose pull
|
||||
docker-compose up -d --build
|
||||
```
|
||||
|
||||
3. **Logs**
|
||||
```bash
|
||||
docker-compose logs -f
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user