Hardening Nginx
Security Headers
Add these to your `http` or `server` block to prevent XSS and clickjacking.
nginx
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "default-src 'self';";Gzip Compression
Reduce bandwidth usage significantly.
nginx
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml+rss text/javascript;Load Balancing
Distribute traffic across two backends.
nginx
upstream backend_hosts {
server 10.0.0.1;
server 10.0.0.2;
}
server {
location / {
proxy_pass http://backend_hosts;
}
}Page changelog
Last updated
- 2024-04-08—Initial or baseline update for this page.
Related articles
Configuration
API Reference — Patterns and Generation
How to design, document, and (when possible) auto-generate reference docs from OpenAPI and source code.
Configuration
Tailwind CSS — Utility-First Styling with Production Discipline
Install Tailwind, build consistent design tokens, and ship fast UI with real CSS examples, components, and best practices.
Configuration
Ant Design — Enterprise UI Components for React
A mature enterprise component library. Learn how to install, theme, and use components with predictable layout and form patterns.
Configuration
MUI (Material UI) — Component Library with Theme Tokens
Build consistent UI fast with MUI themes, component overrides, and practical examples for React/Next.js.
Configuration
Styled Components — CSS-in-JS with Real CSS Snippets
Write component-scoped styles with full CSS power, theming, and patterns for scaling safely.
Configuration
Sass/SCSS — Structured CSS for Large Codebases
Use variables, mixins, and partials to keep CSS maintainable. Includes SCSS examples you can copy/paste.
Was this page helpful?