Cadence Stack Reverse Proxy (Redo) #235
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a redo of #233. #233 originally introduced the reverse proxy service, but broke the rate limiter and SSE, so I'm back again with a more thoughtful approach.
Reverse Proxy Service
The main feature of this PR is a built-in Reverse Proxy service provided by an nginx container which routes inbound connections to the API server and Icecast stream.
Cadence users can now easily serve their radios publicly by simply providing the reverse proxy service with their own domain names.
This naturally forced about some improvements to other parts of Cadence, as you will see.
cadenceradio.com demo deployed using Compose
In order to actually test the reverse proxy service in a production environment, I've moved the demo site, CadenceRadio.com, off my Kubernetes cluster and onto a "traditional" Linux Server using Cadence's Docker Compose.
I had it on my Kubernetes cluster mostly for personal interest reasons, but I may actually keep it deployed through Compose for the foreseeable future since it's how I expect users to actually run their Cadence stacks anyway.
I opened #236 to hopefully make installation for the user even easier.
Rate Limiter Updated
We introduce a better rate limiter IP checker that works with or without the new reverse proxy.
cadence/cadence/server/db_redis.go
Lines 56 to 67 in 7d9fd8b
Reliable SSE
The default reverse proxy configuration provided also reliably handles SSE connections.
cadence/config/nginx.conf
Lines 22 to 31 in 7d9fd8b
UI code is also modified so it will try to close its current SSE connection when it encounters an error before trying to create a new connection.
Error Handling
We added some handling for specific errors related to Postgres DB startup. If a Cadence replica is launched and the metadata database or table already exist, it won't skip repopulation.
cadence/cadence/server/db_postgres.go
Lines 89 to 98 in 7d9fd8b
Reorganization
The repository has been reorganized so there is no longer a top-level directory for Icecast or Liquidsoap. Their Dockerfiles have been moved within a new
stream/
directory.All config files meant for the user to configure have been moved to a new top-level
config/
directory. With everything in one place now and renamed with clarity, it should be simpler for someone to set up a stack.Minor Code Updates
expose
vsports
, and correctingcontext
to a more accuratedockerfile
.This fixes #227.