Fix: Resolve Nginx SSL certificate loading issue
- Created nginx-http-only.conf for initial startup without SSL - Added setup-ssl-improved.sh script that: - Starts app first, then HTTP-only Nginx - Creates SSL certificates via Certbot - Switches to HTTPS configuration after certificate creation - This prevents Nginx from failing on missing SSL certificates during initial startup
This commit is contained in:
139
nginx/nginx-http-only.conf
Normal file
139
nginx/nginx-http-only.conf
Normal file
@@ -0,0 +1,139 @@
|
||||
# Nginx HTTP-only Konfiguration für ersten Start (vor SSL-Zertifikatserstellung)
|
||||
# Optimiert für Produktionsumgebung
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
use epoll;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Logging
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
# Performance-Optimierungen
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 10M;
|
||||
|
||||
# Gzip-Kompression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types
|
||||
text/plain
|
||||
text/css
|
||||
text/xml
|
||||
text/javascript
|
||||
application/json
|
||||
application/javascript
|
||||
application/xml+rss
|
||||
application/atom+xml
|
||||
image/svg+xml;
|
||||
|
||||
# Sicherheits-Header (ohne HSTS für HTTP)
|
||||
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'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self';" always;
|
||||
|
||||
# Rate Limiting
|
||||
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
|
||||
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
|
||||
|
||||
# Upstream für die Anwendung
|
||||
upstream stargirlnails {
|
||||
server stargirlnails:3000;
|
||||
}
|
||||
|
||||
# HTTP-Server (ohne HTTPS-Redirect)
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# Let's Encrypt Challenge
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
}
|
||||
|
||||
# Proxy-Einstellungen
|
||||
proxy_set_header Host $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;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
|
||||
# Timeouts
|
||||
proxy_connect_timeout 30s;
|
||||
proxy_send_timeout 30s;
|
||||
proxy_read_timeout 30s;
|
||||
|
||||
# API-Endpunkte mit Rate Limiting
|
||||
location /rpc {
|
||||
limit_req zone=api burst=20 nodelay;
|
||||
proxy_pass http://stargirlnails;
|
||||
}
|
||||
|
||||
# Login-Endpunkte mit strengerem Rate Limiting
|
||||
location ~ ^/(login|auth) {
|
||||
limit_req zone=login burst=5 nodelay;
|
||||
proxy_pass http://stargirlnails;
|
||||
}
|
||||
|
||||
# Statische Dateien (Assets)
|
||||
location /static/ {
|
||||
proxy_pass http://stargirlnails;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Assets-Verzeichnis
|
||||
location /assets/ {
|
||||
proxy_pass http://stargirlnails;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Favicon
|
||||
location /favicon.ico {
|
||||
proxy_pass http://stargirlnails;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# Health Check
|
||||
location /health {
|
||||
proxy_pass http://stargirlnails;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# Security.txt
|
||||
location /.well-known/security.txt {
|
||||
proxy_pass http://stargirlnails;
|
||||
expires 1d;
|
||||
}
|
||||
|
||||
# Alle anderen Anfragen
|
||||
location / {
|
||||
proxy_pass http://stargirlnails;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user