Add custom error pages and Nginx configuration for proxy module

- Introduced custom HTML error pages for various HTTP status codes (400, 401, 403, 404, 408, 429, 500, 502, 503, 504) in the proxy module.
- Created a .gitignore file to exclude non-HTML files in the error resources directory.
- Updated Nginx configuration to serve custom error pages for upstream errors.
- Added new Nginx configuration templates for handling HTTP and stream protocols.
- Implemented Wireguard configuration templates and associated variables for secure connections.
- Established Kubernetes resources for Stunnel and Wireguard, including deployment, service accounts, and config maps.
- Defined variables for the Stunnel and Wireguard modules to facilitate configuration.
- Created a new Wol Proxy module with Kubernetes resources for deployment and service management.
This commit is contained in:
2025-10-02 00:19:01 +02:00
parent 4d00986273
commit e6a3f3affd
62 changed files with 1517 additions and 99 deletions
@@ -0,0 +1,34 @@
# resource "kubernetes_ingress_v1" "proxy" {
# metadata {
# name = "ingress"
# namespace = kubernetes_namespace.proxy.metadata[0].name
# annotations = {
# "kubernetes.io/ingress.class" = "public"
# "cert-manager.io/cluster-issuer" = "letsencrypt-prod"
# "kubernetes.io/tls-acme" = "true"
# "nginx.ingress.kubernetes.io/ssl-redirect" = "true"
# }
# }
# spec {
# tls {
# hosts = [var.fqdn]
# secret_name = "proxy-tls"
# }
# rule {
# host = var.fqdn
# http {
# path {
# backend {
# service {
# name = "upstream"
# port {
# number = var.proxy_port
# }
# }
# }
# }
# }
# }
# }
# }
@@ -0,0 +1,5 @@
resource "kubernetes_namespace" "proxy" {
metadata {
name = var.namespace
}
}
@@ -0,0 +1,9 @@
terraform {
required_version = "~>1.8"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.36.0"
}
}
}
+123
View File
@@ -0,0 +1,123 @@
resource "kubernetes_service_account" "proxy" {
metadata {
name = "wol-proxy-sa"
namespace = kubernetes_namespace.proxy.metadata[0].name
}
automount_service_account_token = false
}
resource "kubernetes_deployment" "proxy" {
metadata {
name = "wol-proxy"
namespace = kubernetes_namespace.proxy.metadata[0].name
labels = {
app = "wol-proxy"
}
}
spec {
replicas = 1
selector {
match_labels = {
app = "wol-proxy"
}
}
strategy {
type = "Recreate"
}
template {
metadata {
labels = {
app = "wol-proxy"
}
}
spec {
service_account_name = kubernetes_service_account.proxy.metadata[0].name
automount_service_account_token = false
host_network = true
container {
name = "app"
image = "a13labs/wol_proxy:${var.tag}"
image_pull_policy = "Always"
security_context {
capabilities {
add = ["NET_RAW"]
}
}
port {
name = "upstream"
container_port = var.proxy_port
}
env {
name = "UPSTREAM_MAC"
value = var.upstream.mac
}
env {
name = "UPSTREAM_IP"
value = var.upstream.ip
}
env {
name = "UPSTREAM_PORT"
value = var.upstream.port
}
env {
name = "UPSTREAM_SCHEME"
value = var.upstream.scheme
}
env {
name = "PROXY_PORT"
value = var.proxy_port
}
readiness_probe {
tcp_socket {
port = var.proxy_port
}
initial_delay_seconds = 5
period_seconds = 10
failure_threshold = 10
}
}
}
}
}
}
resource "kubernetes_service" "proxy" {
metadata {
name = "upstream"
namespace = kubernetes_namespace.proxy.metadata[0].name
}
spec {
selector = {
app = "wol-proxy"
}
port {
name = "upstream"
port = var.proxy_port
target_port = var.proxy_port
}
}
lifecycle {
ignore_changes = [
metadata[0].annotations
]
}
}
@@ -0,0 +1,32 @@
variable "upstream" {
description = "Configuration for the upstream proxy"
type = object({
mac = optional(string, "")
ip = optional(string, "")
port = optional(string, "")
scheme = optional(string, "http")
})
}
# variable "fqdn" {
# description = "The fully qualified domain name for the app server"
# type = string
# }
variable "tag" {
description = "The version of app to install"
type = string
default = "v0.4.0"
}
variable "namespace" {
description = "The namespace for the proxy"
type = string
default = "wol-proxy"
}
variable "proxy_port" {
description = "The port on which the proxy will listen"
type = number
default = 8080
}