33800 Docs

← Retour

Proposition : Automatisation Nginx + DNS Yellowswitch

Date : 10-12-2025 Statut : EN COURS - SSH à configurer par l'utilisateur


Informations collectées

VM Nginx

Info Valeur
IP 192.168.1.104
User SSH gouroubleu
Hostname (à configurer - optionnel)
Wildcard SSL Déjà configuré (Let's Encrypt)

DNS o2switch (Yellowswitch)

Info Valeur
Provider o2switch
cPanel URL https://yellow.o2switch.net:2083
API UAPI cPanel
Auth cpanel USERNAME:APITOKEN

1. Configuration Nginx dans conf.gouroubleu.yml

name: "hellocar"
services:
  api:
    type: "bun"
    port: 4510
    nginx:
      domain: "hellocar-api-prod.33800.nowhere84.com"
      proxy_pass: "http://192.168.1.11:4510"
      ssl: true
      headers:
        - "X-Real-IP $remote_addr"
        - "X-Forwarded-For $proxy_add_x_forwarded_for"

  public:
    type: "qwik"
    port: 4501
    nginx:
      domain: "hellocar-public-prod.33800.nowhere84.com"
      proxy_pass: "http://192.168.1.11:4501"
      ssl: true
      cache:
        enabled: true
        paths: ["/assets", "/_build"]
        duration: "30d"

  admin:
    type: "qwik"
    port: 4500
    nginx:
      domain: "hellocar-admin-prod.33800.nowhere84.com"
      proxy_pass: "http://192.168.1.11:4500"
      ssl: true

2. API o2switch - Endpoints utiles

Authentification

# Méthode 1 : Header Authorization
curl -H "Authorization: cpanel USERNAME:APITOKEN" \
  "https://yellow.o2switch.net:2083/execute/..."

# Méthode 2 : Basic Auth (alternative)
curl -u "USERNAME:APITOKEN" \
  "https://yellow.o2switch.net:2083/execute/..."

Lister les enregistrements DNS

curl -H "Authorization: cpanel USERNAME:APITOKEN" \
  "https://yellow.o2switch.net:2083/execute/ZoneEdit/fetch_zone_records?domain=nowhere84.com"

Ajouter un enregistrement (wildcard A)

curl -H "Authorization: cpanel USERNAME:APITOKEN" \
  "https://yellow.o2switch.net:2083/execute/ZoneEdit/add_zone_record?domain=nowhere84.com&name=*.33800&type=A&address=IP_PUBLIQUE_NGINX&ttl=3600"

Modifier un enregistrement

curl -H "Authorization: cpanel USERNAME:APITOKEN" \
  "https://yellow.o2switch.net:2083/execute/ZoneEdit/edit_zone_record?domain=nowhere84.com&line=LINE_NUMBER&name=*.33800&type=A&address=NEW_IP&ttl=3600"

Supprimer un enregistrement

curl -H "Authorization: cpanel USERNAME:APITOKEN" \
  "https://yellow.o2switch.net:2083/execute/ZoneEdit/remove_zone_record?domain=nowhere84.com&line=LINE_NUMBER"

3. Secrets à ajouter

Dans /mnt/stock_36to/data/docker/secrets/ :

prod.env et dev.env :

# o2switch cPanel API
O2SWITCH_USERNAME=ton_username_cpanel
O2SWITCH_APITOKEN=ton_api_token
O2SWITCH_DOMAIN=nowhere84.com

Comment créer un API Token sur cPanel :

  1. Connexion à https://yellow.o2switch.net:2083
  2. Section "Sécurité" → "Gérer les tokens d'API"
  3. Créer un nouveau token
  4. Copier le token (visible une seule fois)

4. Template Nginx généré

# Auto-generated by gouroubleu deploy system
# Project: hellocar | Service: api | Env: prod
# Generated: 2025-12-10

server {
    listen 80;
    server_name hellocar-api-prod.33800.nowhere84.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name hellocar-api-prod.33800.nowhere84.com;

    # SSL Wildcard Let's Encrypt
    ssl_certificate /etc/letsencrypt/live/33800.nowhere84.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/33800.nowhere84.com/privkey.pem;

    # SSL Settings
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
    ssl_prefer_server_ciphers off;

    location / {
        proxy_pass http://192.168.1.11:4510;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        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;
        proxy_cache_bypass $http_upgrade;
    }
}

5. Workflow complet de déploiement

┌─────────────────────────────────────────────────────────────┐
│  "mets en prod hellocar"                                    │
├─────────────────────────────────────────────────────────────┤
│  1. Clone GitHub (branche main)                             │
│  2. Build & Deploy Docker sur 192.168.1.11                  │
│  3. Lecture section nginx: du conf.gouroubleu.yml           │
│  4. Génération fichier .conf Nginx                          │
│  5. SSH vers 192.168.1.104 (gouroubleu)                     │
│  6. Vérification conflits :                                 │
│     - diff ancien/nouveau fichier                           │
│     - grep domain dans autres configs                       │
│  7. Copie /etc/nginx/sites-available/{projet}-{svc}-{env}   │
│  8. ln -sf vers sites-enabled/                              │
│  9. sudo nginx -t                                           │
│ 10. sudo systemctl reload nginx                             │
│ 11. Curl test https://domain → 200 OK ?                     │
├─────────────────────────────────────────────────────────────┤
│  DNS (si nouveau sous-domaine hors wildcard)                │
│  → Appel API o2switch pour vérifier/créer                   │
└─────────────────────────────────────────────────────────────┘

6. Étapes à faire

Toi (sur VM Nginx 192.168.1.104) :

Moi (après ta confirmation) :


7. Questions en suspens

  1. Username cPanel o2switch : quel est ton username ?
  2. API Token : as-tu déjà créé un token API ? (sinon à faire sur cPanel)
  3. IP publique de la VM Nginx : quelle est l'IP publique vers laquelle pointe le wildcard DNS ?
  4. Chemin certificat SSL : /etc/letsencrypt/live/33800.nowhere84.com/ ou autre ?

Dis-moi quand SSH est prêt sur 192.168.1.104 !