22proxy_cache_path /var/cache/nginx/dockerhub_cache levels=1:2 keys_zone=dockerhub_cache:10m max_size=1g inactive=60m use_temp_path=off;
33
44server {
5- listen 80;
5+ listen 80; # IPv4
6+ listen [::]:80; # IPv6
7+ # HTTP/2 support (requires SSL)
8+ http2 on;
9+ listen 443 ssl;
10+ listen [::]:443 ssl;
611 server_name localhost;
712
13+ # SSL configuration (required for HTTP/2)
14+ ssl_certificate /etc/nginx/ssl/nginx.crt;
15+ ssl_certificate_key /etc/nginx/ssl/nginx.key;
16+ ssl_protocols TLSv1.3;
17+ ssl_session_cache shared:SSL:10m;
18+ ssl_session_timeout 10m;
19+
20+ # Security headers
21+ add_header X-Content-Type-Options nosniff;
22+ add_header X-Frame-Options SAMEORIGIN;
23+ add_header X-XSS-Protection "1; mode=block";
24+ add_header Referrer-Policy no-referrer-when-downgrade;
25+
26+ # Compression settings
27+ gzip on;
28+ gzip_comp_level 5;
29+ gzip_min_length 4096;
30+ gzip_proxied any;
31+ gzip_vary on;
32+ gzip_types
33+ application/javascript
34+ application/json
35+ application/xml
36+ text/css
37+ text/javascript
38+ text/plain
39+ text/xml;
40+
841 # Default location block for serving static files
942 location / {
1043 root /usr/share/nginx/html;
1144 index index.html index.htm;
1245 try_files $uri $uri/ /index.html;
46+
47+ # Cache control for static assets
48+ location ~* \.(jpg|jpeg|png|webp|gif|ico|svg)$ {
49+ expires 1d;
50+ add_header Cache-Control "public, no-transform, must-revalidate";
51+ }
1352 }
1453
1554 # Error pages configuration
@@ -19,7 +58,7 @@ server {
1958 }
2059
2160 # Proxy configuration for Docker Hub API requests with caching.
22- location /v2/namespaces/pegi3s/repositories/ {
61+ location /v2/namespaces/pegi3s/repositories {
2362 resolver 1.1.1.1; # DNS resolver for domain name lookup.
2463 set $upstream_endpoint https://hub.docker.com; # The upstream service to proxy requests to.
2564
@@ -28,9 +67,18 @@ server {
2867 proxy_cache_valid 200 302 10m; # Cache 200 and 302 responses for 10 minutes
2968 proxy_cache_valid 404 1m; # Cache 404 responses for 1 minute
3069 proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
70+ proxy_cache_lock on; # Prevents multiple clients from requesting the same uncached item.
71+ proxy_cache_background_update on; # Updates cache in background without blocking clients.
3172 add_header X-Proxy-Cache $upstream_cache_status; # Adds a header to the response with the cache status.
3273
3374 # Pass the request to the upstream server
3475 proxy_pass $upstream_endpoint$request_uri;
3576 }
77+
78+ # Deny access to hidden files
79+ location ~ /\. {
80+ deny all;
81+ access_log off;
82+ log_not_found off;
83+ }
3684}
0 commit comments