Compare commits

...

2 Commits

Author SHA1 Message Date
b686486c93 Add DomainRedirect Service 2024-02-20 14:51:36 -08:00
8428e1a269 Add Mailcatcher Service 2024-02-20 13:17:48 -08:00
4 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,52 @@
locals {
HOST = "example.local"
TARGET = "https://example.com/path"
}
job "domainredirect" {
datacenters = ["dc1"]
type = "service"
group "domainredirect" {
count = 1
network {
port "http" {
to = 8080
}
}
service {
name = "domainredirect"
provider = "consul"
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.routers.domainredirect.tls=true",
"traefik.http.routers.domainredirect.entrypoints=websecure",
"traefik.http.routers.domainredirect.rule=Host(`${local.HOST}`)",
]
check {
type = "http"
path = "/health"
interval = "10s"
timeout = "2s"
}
}
task "domainredirect" {
driver = "docker"
config {
image = "git.cbraaten.dev/caleb/domainredirect:latest"
ports = ["http"]
}
env {
REDIRECT_TARGET = local.TARGET
}
}
}
}

View File

@ -0,0 +1,18 @@
# domainredirect
domainredirect is just a redirect service that will redirect any traffic to the url you you specify. This is useful for redirecting traffic from one domain to another.
## Nomad Job for domainredirect
The domainredirect expects a REDIRECT_TARGET environment variable to be set. This is the complete url that the domainredirect will redirect to. You can set it on line 2 of the job spec.
## TODO
If you want to deploy this, you will need to update the domain name in the job spec.
| Line | Default | Adjustment |
| --- | --- | --- |
| 2 | `HOST = "example.local"` | Change `example.local` to the domain you are listening on |
| 3 | `TARGET = "https://example.com/path"` | Change `example.com/path` to your destination |
## Request
If you are deploying this regularly, please consider pulling the image and pushing it to your own registry. This will help reduce the load on my registry and help keep the image available for everyone. (Although it's not that complex, you could also [build the image yourself.](https://git.cbraaten.dev/Caleb/DomainRedirect))

View File

@ -0,0 +1,36 @@
job "mailcatcher" {
datacenters = ["dc1"]
group "mailcatcher" {
count = 1
network {
mode = "bridge"
port "webUI" {
to = 1080
}
}
service {
# Make available to other services by the 'fake-smtp' name
name = "fake-smtp"
port = "1025"
tags = ["traefik.enable=false"] # Hide redis from traefik
connect {
sidecar_service {
tags = ["traefik.enable=false"] # Hide redis envoy from traefik
}
}
}
task "mailcatcher" {
driver = "docker"
config {
image = "sj26/mailcatcher:latest"
ports = ["webUI"]
}
}
}
}

View File

@ -0,0 +1,7 @@
# Mailcatcher
Mailcatcher is a simple SMTP server that catches all mail sent to it and displays it in a web interface. This is useful for development and testing of email sending services. This is not a production ready service and should not be used in a production environment.
## Nomad Job for Mailcatcher
Mailcatcher requires no configuration but is only available through the service mesh for sending SMTP mail. The service to connect to is fittingly called `fake-smtp` and is available to the localhost on port `1025`. There is no need for an email or password and the service is not encrypted so you should not use TLS or SSL. (It might work, I just haven't tried it.) - This is not something you should expose to the internet. It's just for testing and development.
Once you have sent an email to the fake SMTP server, you can view the email in the web interface. The web interface has a dynamic port assigned by Nomad so you will need to go to the Task Allocation page in the Nomad UI where you can open the link under 'WebUI' to view the emails.