sozu-proxy / sozu

Sōzu HTTP reverse proxy, configurable at runtime, fast and safe, built in Rust. It is awesome!
https://www.sozu.io/
GNU Affero General Public License v3.0
3.12k stars 193 forks source link

how to use for multiple ports? #1035

Closed 0xBYTESHIFT closed 12 months ago

0xBYTESHIFT commented 1 year ago

so, I want to use the same sozy instance to proxy traffic to two different applications. I hope it's possible, since there's a possibility to set it up for multiple listeners. But for some reason, I see that only one backend gets requests.

Here's my config:

# command_socket = "./command_folder/sock"
saved_state = "./state.json"
log_level = "info"
log_target = "stdout"
command_buffer_size = 16384
worker_count = 2
handle_process_affinity = false
max_connections = 100
max_buffers = 100
buffer_size = 16384
activate_listeners = true

[[listeners]]
protocol = "tcp"
address = "0.0.0.0:1965" # for gemini

[[listeners]]
protocol = "http"
address = "0.0.0.0:3001" # for grafana

[clusters.PI_gemini]
protocol = "tcp"
frontends = [
  { address = "0.0.0.0:1965" } 
]

backends  = [
  { address = "123.123.123.123:1965" }
]

[clusters.PI_grafana]
protocol = "http"
frontends = [
  { address = "0.0.0.0:3001", hostname = "valid.hostname.com" },
]

backends  = [
  { address = "123.123.123.123:3000" }
]

or, in short terms: 0.0.0.0:1965 -> 123.123.123.123:1965 0.0.0.0:3001 -> 123.123.123.123:3000

it launches just fine, but the :3001 proxy route doesn't work at all. I can see logs when I curl :1965, both in sozu and backend. But with :3001, there's nothing even in the sozu logs. So I believe I misunderstood the configuration examples, or there's something wrong on the other level 🤔

Wonshtrum commented 1 year ago

Hi! It seems to work on my machine, how did you try to join the 3001 route? Personally, it worked with this command:

curl -v http://valid.hostname.com:3001 --resolve valid.hostname.com:3001:0.0.0.0
* Added valid.hostname.com:3001:127.0.0.1 to DNS cache
* Hostname valid.hostname.com was found in DNS cache
*   Trying 127.0.0.1:3001...
* Connected to valid.hostname.com (127.0.0.1) port 3001 (#0)
> GET / HTTP/1.1
> Host: valid.hostname.com:3001
> User-Agent: curl/7.88.1
> Accept: */*
> 
< HTTP/1.1 504 Gateway Timeout
< Cache-Control: no-cache
< Connection: close
< 
* Closing connection 0

Three things to note that you potentially missed: