Forum software (phpBB, Discourse, XenForo, vBulletin) shares one challenge: user-generated content with embedded HTML, images and links from countless external sources. Strict Content-Security-Policy will break embeds, signatures and user avatars. This guide covers every fix our Security Audit raises on forum software, with forum-aware CSP patterns that don't break user content. Covers phpBB 3.3, Discourse 3.3 and XenForo 2.3.
Forum security headers go at the web-server layer (nginx or Apache), not in the forum software itself. First identify whether your forum runs on Apache or nginx:
The default strict CSP will break: user avatars from Gravatar/external hosts, embedded YouTube/Vimeo, image hotlinks in posts, signatures with external images. Use this more permissive CSP for forums:
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; media-src 'self' https:; frame-src 'self' https://www.youtube.com https://player.vimeo.com; connect-src 'self'; frame-ancestors 'self'
img-src https: permits any HTTPS image — necessary for user avatars and hotlinks. The frame-src whitelist permits YouTube and Vimeo embeds.phpBB has built-in security settings in the ACP:
https://, Force server URL settings Yes. Save.Discourse runs in Docker and manages its own nginx internally. Custom headers go in app.yml:
cd /var/discourse nano containers/app.ymlDiscourse has a documented pattern for custom headers via the
hooks: section. Reference Discourse meta documentation for current syntax — they update it periodically../launcher rebuild appDiscourse rebuilds the container with your changes.
XenForo has an option for HSTS in admin config; the rest comes from your web server.
https://forum.yourdomain.com.curl -sI https://forum.yourdomain.com/ | grep -iE "strict-transport|x-frame|x-content|referrer|permissions|content-security"Re-run the Security Audit.
Verify every header, TLS protocol and security.txt with a fresh scan.
Run Security Audit →