# Apache 2 VirtualHost-Konfiguration für TimeClock v3 # Datei speichern unter: /etc/apache2/sites-available/stechuhr3.tsschulz.de.conf # # Installation: # sudo cp apache2.conf /etc/apache2/sites-available/stechuhr3.tsschulz.de.conf # sudo a2enmod proxy proxy_http ssl rewrite headers deflate expires # sudo a2ensite stechuhr3.tsschulz.de # sudo apache2ctl configtest # sudo systemctl reload apache2 # HTTP VirtualHost - Redirect zu HTTPS ServerName stechuhr3.tsschulz.de ServerAdmin admin@tsschulz.de # Let's Encrypt ACME Challenge DocumentRoot /var/www/certbot Require all granted # Alle anderen Requests zu HTTPS umleiten RewriteEngine On RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/ RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] ErrorLog ${APACHE_LOG_DIR}/stechuhr3-error.log CustomLog ${APACHE_LOG_DIR}/stechuhr3-access.log combined # HTTPS VirtualHost - Hauptkonfiguration ServerName stechuhr3.tsschulz.de ServerAdmin admin@tsschulz.de # ================================================================= # SSL-Konfiguration (wird von Certbot automatisch verwaltet) # ================================================================= SSLEngine on SSLCertificateFile /etc/letsencrypt/live/stechuhr3.tsschulz.de/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/stechuhr3.tsschulz.de/privkey.pem # SSL-Protokolle und Cipher Suites SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 SSLCipherSuite 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 SSLHonorCipherOrder off SSLSessionTickets off # OCSP Stapling SSLUseStapling on SSLStaplingResponderTimeout 5 SSLStaplingReturnResponderErrors off # ================================================================= # Frontend (Vue.js SPA) # ================================================================= DocumentRoot /var/www/timeclock/frontend/dist Options -Indexes +FollowSymLinks AllowOverride All Require all granted # SPA Fallback - alle Requests zu index.html RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/api RewriteRule . /index.html [L] # ================================================================= # Gzip Compression # ================================================================= AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json AddOutputFilterByType DEFLATE application/xml application/xml+rss application/rss+xml AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE font/ttf font/woff font/woff2 # ================================================================= # Security Headers # ================================================================= # X-Frame-Options: Schutz vor Clickjacking Header always set X-Frame-Options "SAMEORIGIN" # X-Content-Type-Options: Verhindert MIME-Type Sniffing Header always set X-Content-Type-Options "nosniff" # X-XSS-Protection: XSS-Schutz für ältere Browser Header always set X-XSS-Protection "1; mode=block" # Referrer-Policy: Kontrolliert Referrer-Informationen Header always set Referrer-Policy "strict-origin-when-cross-origin" # Permissions-Policy: Kontrolliert Browser-Features Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()" # Content-Security-Policy (angepasst für Vue.js) Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://stechuhr3.tsschulz.de;" # Strict-Transport-Security (HSTS) Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" # ================================================================= # API Reverse Proxy zum Backend # ================================================================= ProxyPreserveHost On ProxyRequests Off # Timeouts ProxyTimeout 60 # API Proxy ProxyPass /api http://localhost:3010/api retry=0 ProxyPassReverse /api http://localhost:3010/api # Proxy Headers RequestHeader set X-Forwarded-Proto "https" RequestHeader set X-Forwarded-Port "443" RequestHeader set X-Real-IP %{REMOTE_ADDR}s # CORS Headers (falls benötigt, aber Backend sollte das handhaben) # Header set Access-Control-Allow-Origin "https://stechuhr3.tsschulz.de" # Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" # Header set Access-Control-Allow-Headers "Content-Type, Authorization" # Header set Access-Control-Allow-Credentials "true" # ================================================================= # Statische Assets mit langem Cache # ================================================================= ExpiresActive On # JavaScript und CSS ExpiresByType text/css "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType application/x-javascript "access plus 1 year" # Bilder ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/webp "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType image/x-icon "access plus 1 year" # Fonts ExpiresByType font/ttf "access plus 1 year" ExpiresByType font/woff "access plus 1 year" ExpiresByType font/woff2 "access plus 1 year" ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/font-woff2 "access plus 1 year" # HTML (kein Cache) ExpiresByType text/html "access plus 0 seconds" # Cache-Control Headers für Assets Header set Cache-Control "public, max-age=31536000, immutable" # Kein Cache für HTML Header set Cache-Control "no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "0" # ================================================================= # Spezielle Dateien # ================================================================= # robots.txt und sitemap.xml Header set Cache-Control "public, max-age=86400" # ================================================================= # Sicherheit: Verstecke sensible Dateien # ================================================================= # Blockiere Zugriff auf versteckte Dateien (.git, .env, etc.) Require all denied Require all denied # Blockiere Zugriff auf Backup-Dateien Require all denied # Blockiere .env Dateien Require all denied # ================================================================= # Limits # ================================================================= # Client Body Size Limit (z.B. für File-Uploads) LimitRequestBody 10485760 # Timeouts TimeOut 300 # ================================================================= # Logging # ================================================================= ErrorLog ${APACHE_LOG_DIR}/stechuhr3-error.log CustomLog ${APACHE_LOG_DIR}/stechuhr3-access.log combined # Optional: Log-Level für detailliertere Logs # LogLevel info ssl:warn proxy:debug # ================================================================= # Globale SSL-Konfiguration (optional, in /etc/apache2/mods-available/ssl.conf) # ================================================================= # # # OCSP Stapling Cache # SSLStaplingCache shmcb:/var/run/ocsp(128000) # # # SSL Session Cache # SSLSessionCache shmcb:/var/run/ssl_scache(512000) # SSLSessionCacheTimeout 300 # # ================================================================= # OPTIONAL: Rate Limiting mit mod_evasive # ================================================================= # Installieren mit: sudo apt install libapache2-mod-evasive # Dann konfigurieren in: /etc/apache2/mods-available/evasive.conf # # # DOSHashTableSize 3097 # DOSPageCount 5 # DOSSiteCount 100 # DOSPageInterval 1 # DOSSiteInterval 1 # DOSBlockingPeriod 10 # DOSEmailNotify admin@tsschulz.de # DOSLogDir /var/log/apache2/mod_evasive # # ================================================================= # OPTIONAL: Zusätzliche Security mit mod_security # ================================================================= # Installieren mit: sudo apt install libapache2-mod-security2 # Konfiguration in: /etc/modsecurity/modsecurity.conf