99 lines
3.3 KiB
Plaintext
99 lines
3.3 KiB
Plaintext
server {
|
|
listen 443 ssl; #http2;
|
|
listen [::]:443 ssl; # http2;
|
|
server_name harbor.novicelab.io;
|
|
|
|
# SSL Certificate paths
|
|
ssl_certificate /etc/letsencrypt/live/novicelab.io/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/novicelab.io/privkey.pem;
|
|
|
|
# SSL Protocol - TLS 1.2 and 1.3 only
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
# Cipher suites (prioritize TLS 1.3, secure TLS 1.2 fallback)
|
|
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
|
ssl_prefer_server_ciphers off;
|
|
|
|
# SSL session configuration
|
|
ssl_session_timeout 1d;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_tickets off;
|
|
|
|
resolver 127.0.0.11 8.8.8.8 8.8.4.4 valid=300s;
|
|
resolver_timeout 5s;
|
|
|
|
# Security Headers
|
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
add_header Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';" always;
|
|
|
|
# Logging
|
|
access_log /var/log/nginx/harbor.novicelab.io_access.log;
|
|
error_log /var/log/nginx/harbor.novicelab.io_error.log;
|
|
|
|
# set $harbor_backend 10.0.0.251:9090;
|
|
set $harbor_backend nginx-harbor:80;
|
|
|
|
client_max_body_size 0;
|
|
|
|
# Disable absolute redirects which often cause 301 loops
|
|
absolute_redirect off;
|
|
|
|
# Docker registry specific headers
|
|
chunked_transfer_encoding on;
|
|
|
|
location / {
|
|
proxy_pass http://$harbor_backend;
|
|
proxy_set_header Host $http_host;
|
|
# proxy_set_header X-Real-IP $remote_addr;
|
|
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
# proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# WebSocket support for real-time updates
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
client_max_body_size 0;
|
|
|
|
# Timeouts
|
|
proxy_connect_timeout 300;
|
|
proxy_send_timeout 300;
|
|
proxy_read_timeout 300;
|
|
send_timeout 300;
|
|
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass_header Authorization;
|
|
|
|
# Performance optimizations
|
|
proxy_request_buffering off;
|
|
|
|
proxy_buffering off;
|
|
proxy_set_header Referer $http_referer;
|
|
proxy_redirect off;
|
|
|
|
proxy_set_header Cookie $http_cookie;
|
|
|
|
|
|
# Optional: Increase buffers for large tokens/cookies
|
|
proxy_busy_buffers_size 512k;
|
|
proxy_buffers 4 512k;
|
|
proxy_buffer_size 256k;
|
|
}
|
|
|
|
location /v2/ {
|
|
# Do not allow Nginx to add/remove trailing slashes here
|
|
proxy_pass http://$harbor_backend;
|
|
|
|
proxy_set_header Host $http_host; # Important for Registry
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Increase body size for image uploads
|
|
client_max_body_size 0;
|
|
}
|
|
} |