user  nginx;
worker_processes  auto;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    # Logs (optionnel)
    access_log  /var/log/nginx/access.log;
    error_log   /var/log/nginx/error.log;

    # ------------------------------
    # 1. Juice Shop (default port)
    # ------------------------------
    server {
        listen 80;
        server_name juice.lab;
        location / {
            proxy_pass http://juice-shop:3000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

    # ------------------------------
    # 2. WebGoat (default port)
    # ------------------------------
    server {
        listen 80;
        server_name webgoat.lab;

        location / {
            proxy_pass http://webgoat:8080/;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_cookie_path /WebGoat /;
            proxy_redirect off;
        }
    }

    # ------------------------------
    # 3. WebWolf (default port)
    # ------------------------------
    server {
        listen 80;
        server_name webwolf.lab;

        location / {
            proxy_pass http://webgoat:9090/;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_cookie_path /WebWolf /;
            proxy_redirect off;
        }
    }

    # ------------------------------
    # 4. bWAPP
    # ------------------------------
    server {
        listen 80;
        server_name bwapp.lab;
        location / {
            proxy_pass http://bwapp;
        }
    }

    # ------------------------------
    # 5. NodeGoat
    # ------------------------------
    server {
        listen 80;
        server_name nodegoat.lab;
        location / {
            proxy_pass http://nodegoat:4000;
        }
    }

    # ------------------------------
    # 6. VAmPI
    # ------------------------------
    server {
        listen 80;
        server_name vampi.lab;
        location / {
            proxy_pass http://vampi:5000;
        }
    }

    # ------------------------------
    # 7. Metasploitable2
    # ------------------------------
    server {
        listen 80;
        server_name ms2.lab;
        location / {
            proxy_pass http://192.168.20.104:80;
            proxy_set_header Host $host;
        }
    }

    server {
        listen 80;
        server_name ms2-8180.lab;
        location / {
            proxy_pass http://192.168.20.104:8180;
            proxy_set_header Host $host;
        }
    }

    # ------------------------------
    # 8. Metasploitable3 Linux
    # ------------------------------
    server {
        listen 80;
        server_name ms3linux.lab;
        location / {
            proxy_pass http://192.168.20.106:80;
            proxy_set_header Host $host;
        }
    }

    server {
        listen 80;
        server_name ms3linux-8080.lab;
        location / {
            proxy_pass http://192.168.20.106:8080;
            proxy_set_header Host $host;
        }
    }

    # ------------------------------
    # 9. Metasploitable3 Windows
    # ------------------------------
    server {
        listen 80;
        server_name ms3win.lab;
        location / { proxy_pass http://192.168.20.107:80; proxy_set_header Host $host; }
    }

    server {
        listen 80;
        server_name ms3win-8282.lab;
        location / { proxy_pass http://192.168.20.107:8282; proxy_set_header Host $host; }
    }

    server {
        listen 80;
        server_name ms3win-8484.lab;
        location / { proxy_pass http://192.168.20.107:8484; proxy_set_header Host $host; }
    }

    server {
        listen 80;
        server_name ms3win-4848.lab;
        location / { proxy_pass https://192.168.20.107:4848; proxy_set_header Host $host; }
    }

    server {
        listen 80;
        server_name ms3win-8585.lab;
        location / { proxy_pass http://192.168.20.107:8585; proxy_set_header Host $host; }
    }
}