Docker: interner nginx statt socat (Host-Header -> localhost)

Ursache des 404 bei Zugriff über IP/Proxy: .NET-HttpListener bedient den Prefix
http://localhost:8077/ nur bei Host: localhost. socat (L4) reicht den originalen
Host-Header durch -> 404. Jetzt sitzt ein winziger nginx im Container davor, der
den Host-Header auf localhost umschreibt (Upstream [::1]:8077, IPv4 als Fallback).
App-Code bleibt unverändert.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-21 14:35:24 +02:00
co-authored by Claude Opus 4.8
parent c217f5f8f3
commit f40be6e4bd
5 changed files with 55 additions and 25 deletions
+31
View File
@@ -0,0 +1,31 @@
# Interner Reverse-Proxy im Container.
# Zweck: den Host-Header auf "localhost" umschreiben. Die App bindet den
# HttpListener-Prefix http://localhost:8077/ und bedient NUR Requests mit
# Host: localhost - ohne dieses Rewrite kaeme von aussen 404.
worker_processes 1;
events { worker_connections 1024; }
http {
access_log /dev/stdout;
error_log /dev/stderr;
# App-Listener: bevorzugt IPv6-Loopback (so bindet HttpListener "localhost"
# im Container), IPv4 als Fallback.
upstream imapp {
server [::1]:8077;
server 127.0.0.1:8077 backup;
}
server {
listen 8080;
listen [::]:8080;
location / {
proxy_pass http://imapp;
proxy_set_header Host localhost; # <- der entscheidende Punkt
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_read_timeout 300s; # Device-Code-Login/Graph koennen dauern
}
}
}