3 Commits
Maxi ... rose

Author SHA1 Message Date
Robert Ose
dffd843d3e test 2025-12-17 12:56:16 +01:00
Maximilian Walzer
9eb3c33485 HTTPS Setup mit Docker, Nginx und Let's Encrypt 2025-12-17 11:37:09 +01:00
a25bf263ea Update Dockerfile 2025-12-17 09:29:43 +00:00
4 changed files with 86 additions and 1 deletions

View File

@@ -1,3 +1,3 @@
FROM nginx:alpine FROM nginx:alpine
COPY . /usr/share/nginx/html COPY . /usr/share/nginx/html
EXPOSE 80 EXPOSE 8080

35
docker-compose.yaml Normal file
View File

@@ -0,0 +1,35 @@
version: "3.8"
services:
app:
build: ./app
volumes:
- ./app:/usr/share/nginx/html
expose:
- "80"
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./certbot/www:/var/www/certbot
- ./certbot/conf:/etc/letsencrypt
depends_on:
- app
restart: always
certbot:
image: certbot/certbot
volumes:
- ./certbot/www:/var/www/certbot
- ./certbot/conf:/etc/letsencrypt
entrypoint: >
sh -c "trap exit TERM;
while :; do
certbot renew;
sleep 12h & wait $${!};
done"

50
nginx/default.conf Normal file
View File

@@ -0,0 +1,50 @@
# HTTP → HTTPS Redirect + ACME Challenge
server {
listen 80;
server_name sanke.s-martika.com;
# ACME Challenge für Let's Encrypt
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# Alle anderen HTTP-Anfragen auf HTTPS umleiten
location / {
return 301 https://$host$request_uri;
}
}
# Nginx Metrics für Prometheus
server {
listen 8081; # interner Port nur für Exporter
server_name snake.s-martika.com;
location /status {
stub_status;
allow all;
}
}
# HTTPS Server
server {
listen 443 ssl http2;
server_name example.com;
# Pfad zu den Zertifikaten
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
# Weiterleitung an den App-Container
location / {
proxy_pass http://app:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
}
}