Fix syslog proxy

Apparently traefik only supports http proxy over connect.

https://github.com/traefik/traefik/issues/7803
This commit is contained in:
IamTheFij 2022-09-04 20:21:02 -07:00
parent 34a5ce8141
commit 1be855e571
2 changed files with 44 additions and 14 deletions

View File

@ -92,13 +92,6 @@ EOF
group "syslogng" { group "syslogng" {
count = 1 count = 1
constraint {
attribute = "${node.unique.name}"
# Needs to be on a predictable node for routing
# Maybe a loadbalancer could be used for routing from any node
value = "n2"
}
network { network {
mode = "bridge" mode = "bridge"
port "main" { port "main" {
@ -113,6 +106,8 @@ EOF
connect { connect {
sidecar_service { sidecar_service {
proxy { proxy {
local_service_port = 514
upstreams { upstreams {
destination_name = "syslogng-promtail" destination_name = "syslogng-promtail"
local_bind_port = 1000 local_bind_port = 1000
@ -128,13 +123,6 @@ EOF
} }
} }
} }
tags = [
"traefik.enable=true",
"traefik.tcp.routers.syslogngtcp.entrypoints=syslogtcp",
"traefik.tcp.routers.syslogngtcp.rule=HostSNI(`*`)",
"traefik.udp.routers.syslogngudp.entrypoints=syslogudp",
]
} }
task "syslogng" { task "syslogng" {

View File

@ -32,9 +32,14 @@ job "traefik" {
port "web" { port "web" {
static = 80 static = 80
} }
port "websecure" { port "websecure" {
static = 443 static = 443
} }
port "syslog" {
static = 514
}
} }
ephemeral_disk { ephemeral_disk {
@ -224,6 +229,43 @@ CF_ZONE_API_TOKEN={{ .Data.data.api_token_zone_read }}
change_mode = "noop" change_mode = "noop"
} }
template {
data = <<EOH
{{ with service "syslogng" -}}
[tcp.routers]
[tcp.routers.syslogtcp]
entryPoints = ["syslogtcp"]
service = "syslogngtcp"
rule = "HostSNI(`*`)"
[tcp.services]
[tcp.services.syslogngtcp]
[tcp.services.syslogngtcp.loadBalancer]
{{ range . -}}
[[tcp.services.syslogngtcp.loadBalancer.servers]]
address = "{{ .Address }}:{{ .Port }}"
{{ end -}}
{{ end }}
{{ with service "syslogng" -}}
[udp.routers]
[udp.routers.syslogudp]
entryPoints = ["syslogudp"]
service = "syslogngudp"
[udp.services]
[udp.services.syslogngudp]
[udp.services.syslogngudp.loadBalancer]
{{ range . -}}
[[udp.services.syslogngudp.loadBalancer.servers]]
address = "{{ .Address }}:{{ .Port }}"
{{ end -}}
{{ end }}
EOH
destination = "local/config/conf/route-syslog-ng.toml"
change_mode = "noop"
}
template { template {
data = <<EOH data = <<EOH
[http.middlewares] [http.middlewares]