Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nginx/conf.d/edge.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ server {
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
add_header X-Frame-Options DENY always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
add_header Content-Security-Policy "default-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'self'" always;
# Enable HSTS only on a real HTTPS hostname after confirming rollout.

limit_conn client_conn 50;

location = /health {
access_log off;
add_header Content-Type text/plain;
default_type text/plain;
return 200 'routekernel ok\n';
}

Expand Down
8 changes: 8 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ def test_security_headers_and_hardening(self):
self.assertIn('add_header X-Content-Type-Options nosniff always;', cfg)
self.assertIn('add_header Referrer-Policy strict-origin-when-cross-origin always;', cfg)
self.assertIn('add_header X-Frame-Options DENY always;', cfg)
self.assertIn('add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;', cfg)
self.assertIn("add_header Content-Security-Policy \"default-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'self'\" always;", cfg)
self.assertIn('http2 on;', cfg)
self.assertIn('limit_conn client_conn 50;', cfg)

def test_health_location_preserves_inherited_security_headers(self):
cfg = load('nginx/conf.d/edge.conf')
health_block = cfg.split('location = /health {')[1].split('}', 1)[0]
self.assertIn('default_type text/plain;', health_block)
self.assertNotIn('add_header', health_block)

def test_proxy_forwarding_invariants(self):
proxy = load('nginx/snippets/proxy.conf')
self.assertIn('proxy_http_version 1.1;', proxy)
Expand Down
Loading