initial commit

This commit is contained in:
2025-10-12 18:41:02 +02:00
commit 75347648bc
6 changed files with 107 additions and 0 deletions

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
#FROM nginx
#COPY static-html-directory /usr/share/nginx/html
FROM nginx:stable-alpine
# Copy static site (optional, if you want to serve anything at / directly)
COPY static-html-directory /usr/share/nginx/html
# Replace all default confs with ours
COPY nginx-conf/default.conf /etc/nginx/conf.d/default.conf

27
docker-compose.yml Normal file
View File

@ -0,0 +1,27 @@
version: "3.9"
services:
nginx:
container_name: mynginx
build:
context: . # mappen där Dockerfile finns
dockerfile: Dockerfile # din Dockerfile (från frågan)
ports:
- "80:80" # exponerar HTTP till HAProxy
restart: unless-stopped
networks:
- web
- infra-net
healthcheck:
test: ["CMD-SHELL", "wget -q -O- http://localhost/health || exit 1"]
interval: 10s
timeout: 3s
retries: 5
networks:
web:
external: true # använder redan befintligt nät
name: web
infra-net:
external: true # använder redan befintligt nät
name: infra-net

52
nginx-conf/default.conf Normal file
View File

@ -0,0 +1,52 @@
server {
listen 80;
server_name rubble.se localhost;
# (valfritt) statiskt default
root /usr/share/nginx/html;
index index.html;
# OBS: låt / flöda sist, annars kan try_files vinna över prefixen
# ---- Flappy (som tidigare) ----
location ^~ /flappy/ {
proxy_pass http://flappy/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
rewrite ^/flappy(/.*)$ $1 break;
}
location = /flappy { return 301 /flappy/; }
# ---- HemHub API under /hemhub ----
location ^~ /hemhub/ {
# Viktigt: denna fångar även /hemhub/auth/, så vi behöver en mer specifik block nedan
proxy_pass http://hemhub-api:8080/; # trailing slash => strippar /hemhub/
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 https;
proxy_redirect off;
}
# ---- Keycloak under /hemhub/auth ----
# Mer specifik => placera DENNA FÖRE /hemhub/ eller använd ^~ (gör vi här)
location ^~ /hemhub/auth/ {
proxy_pass http://kc-main:8080/; # trailing slash => strippar /hemhub/auth/
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 https;
proxy_redirect off;
}
# ---- Health ----
location = /health {
return 200 "ok\n";
add_header Content-Type text/plain;
}
# ---- Default root sist (så att prefix-blocken alltid vinner) ----
location / {
try_files $uri $uri/ =404;
}
}

14
start.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
#docker run --detach \
# -p 81:80 \
# --name nginx \
# --restart unless-stopped \
# urmo/nginx:latest
docker run -d \
--name mysite-nginx \
--network web \
-p 80:80 \
--restart unless-stopped \
nginx

View File

@ -0,0 +1,5 @@
<html>
<body>
<h2>Here be dragons</h2>
</body>
</html>