redirect all non-matched urls to the docs.

This commit is contained in:
Erik Brakkee 2024-07-21 15:43:54 +02:00
parent 1307295e20
commit 33e23b69bd
3 changed files with 16 additions and 12 deletions

View File

@ -6,14 +6,12 @@ COPY . /opt/converge/
WORKDIR /opt/converge WORKDIR /opt/converge
RUN go mod download RUN go mod download
COPY . /opt/converge/ COPY . /opt/converge/
#RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main .
RUN go build -ldflags "-linkmode 'external' -extldflags '-static'" -o bin ./cmd/... RUN go build -ldflags "-linkmode 'external' -extldflags '-static'" -o bin ./cmd/...
#RUN mkdir -p /opt/converge/downloads/
FROM scratch FROM scratch
COPY --from=builder /opt/converge/bin/converge /opt/converge/bin/ COPY --from=builder /opt/converge/bin/converge /opt/converge/bin/
COPY --from=builder /opt/converge/bin/agent /opt/converge/bin/tcptows /opt/converge/downloads/ COPY --from=builder /opt/converge/bin/agent /opt/converge/bin/tcptows /opt/converge/docs/
COPY --from=builder /opt/converge/static/ /opt/converge/downloads/ COPY --from=builder /opt/converge/static/ /opt/converge/docs/
ENTRYPOINT ["/opt/converge/bin/converge", "/opt/converge/downloads" ] ENTRYPOINT ["/opt/converge/bin/converge", "/opt/converge/docs" ]

View File

@ -20,6 +20,11 @@ func parsePublicId(path string) (publicId string, _ error) {
return matches[1], nil return matches[1], nil
} }
func catchAllHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/docs", http.StatusFound)
return
}
func main() { func main() {
downloadDir := "downloads" downloadDir := "downloads"
@ -60,7 +65,8 @@ func main() {
http.HandleFunc("/agent/", registrationService.Handle) http.HandleFunc("/agent/", registrationService.Handle)
http.HandleFunc("/client/", clientService.Handle) http.HandleFunc("/client/", clientService.Handle)
http.Handle("/downloads/", http.StripPrefix("/downloads/", http.FileServer(http.Dir(downloadDir)))) http.Handle("/docs/", http.StripPrefix("/docs/", http.FileServer(http.Dir(downloadDir))))
http.HandleFunc("/", catchAllHandler)
// Start HTTP server // Start HTTP server
fmt.Println("Rendez-vous server listening on :8000") fmt.Println("Rendez-vous server listening on :8000")

View File

@ -23,12 +23,12 @@
</p> </p>
<pre> <pre>
# for HTTP hosted server # for HTTP hosted server
curl http://HOSTPORT/downloads/agent > agent curl http://HOSTPORT/docs/agent > agent
./agent ws://HOST:PORT/agent/ID ./agent ws://HOST:PORT/agent/ID
chmod 755 agent chmod 755 agent
# for HTTPS hosted server # for HTTPS hosted server
curl https://HOSTPORT/downloads/agent > agent curl https://HOSTPORT/docs/agent > agent
./agent wss://HOST:PORT/agent/ID ./agent wss://HOST:PORT/agent/ID
chmod 755 agent chmod 755 agent
</pre> </pre>
@ -51,12 +51,12 @@
<pre> <pre>
# for HTTP hosted server # for HTTP hosted server
curl http://HOST:PORT/downloads/wstotcp > wstotcp curl http://HOST:PORT/docs/wstotcp > wstotcp
chmod 755 wstotcp chmod 755 wstotcp
./wstotcp 10000 ws://HOST:PORT/client/ID ./wstotcp 10000 ws://HOST:PORT/client/ID
# for HTTPS hosted server # for HTTPS hosted server
curl https://HOST:PORT/downloads/wstotcp > wstotcp curl https://HOST:PORT/docs/wstotcp > wstotcp
chmod 755 wstotcp chmod 755 wstotcp
./wstotcp 10000 wss://HOST:PORT/client/ID ./wstotcp 10000 wss://HOST:PORT/client/ID
</pre> </pre>
@ -81,9 +81,9 @@
<h1>Downloads</h1> <h1>Downloads</h1>
<ul> <ul>
<li><a href="/downloads/agent">agent</a>: The agent to run inside aa CI job <li><a href="/docs/agent">agent</a>: The agent to run inside aa CI job
</li> </li>
<li><a href="/downloads/tcptows">tcptows</a>: TCP to WS tunnel for allowing regular <li><a href="/docs/tcptows">tcptows</a>: TCP to WS tunnel for allowing regular
SSH and SFTP clients to connect to converge. SSH and SFTP clients to connect to converge.
</li> </li>
</ul> </ul>