[PR #34] [MERGED] feat: Add optional StartEndpoint support for idle watcher #144

Closed
opened 2025-12-29 14:25:39 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/yusing/godoxy/pull/34
Author: @polds
Created: 1/8/2025
Status: Merged
Merged: 1/8/2025
Merged by: @yusing

Base: v0.8Head: feat/idle-watcher-path


📝 Commits (1)

  • c6a37cc feat: Add optional StartEndpoint support for idle watcher

📊 Changes

5 files changed (+116 additions, -37 deletions)

View changed files

📝 internal/docker/container.go (+22 -20)
📝 internal/docker/idlewatcher/types/config.go (+33 -10)
internal/docker/idlewatcher/types/config_test.go (+47 -0)
📝 internal/docker/idlewatcher/waker_http.go (+6 -0)
📝 internal/docker/labels.go (+8 -7)

📄 Description

Optionally allow a user to specify a “warm-up” endpoint to start the container, returning a 403 if the endpoint isn’t hit and the container has been stopped.

This can help prevent bots from starting random containers, or allow health check systems to run some probes. Or potentially lock the start endpoints behind a different authentication mechanism, etc.

Sample service showing this:

  hello-world:
    image: nginxdemos/hello
    container_name: hello-world
    restart: "no"
    ports:
      - "9100:80"
    labels:
      proxy.aliases: hello-world
      proxy.#1.port: 9100
      proxy.idle_timeout: 45s
      proxy.wake_timeout: 30s
      proxy.stop_method: stop
      proxy.stop_timeout: 10s
      proxy.stop_signal: SIGTERM
      proxy.start_endpoint: "/start"

Hitting / on this service when the container is down:

$ curl -sv -X GET -H "Host: hello-world.godoxy.local" http://localhost/
* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
> GET / HTTP/1.1
> Host: hello-world.godoxy.local
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 403 Forbidden
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Wed, 08 Jan 2025 02:04:51 GMT
< Content-Length: 71
< 
Forbidden: Container can only be started via configured start endpoint
* Connection #0 to host localhost left intact

Hitting /start when the container is down:

curl -sv -X GET -H "Host: hello-world.godoxy.local" -H "X-Goproxy-Check-Redirect: skip" http://localhost/start
* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:80...
* Connected to localhost (::1) port 80
> GET /start HTTP/1.1
> Host: hello-world.godoxy.local
> User-Agent: curl/8.7.1
> Accept: */*
> X-Goproxy-Check-Redirect: skip
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Date: Wed, 08 Jan 2025 02:13:39 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/yusing/godoxy/pull/34 **Author:** [@polds](https://github.com/polds) **Created:** 1/8/2025 **Status:** ✅ Merged **Merged:** 1/8/2025 **Merged by:** [@yusing](https://github.com/yusing) **Base:** `v0.8` ← **Head:** `feat/idle-watcher-path` --- ### 📝 Commits (1) - [`c6a37cc`](https://github.com/yusing/godoxy/commit/c6a37cca8a1c7d80c477724a6cbba5f99e9fd9fd) feat: Add optional StartEndpoint support for idle watcher ### 📊 Changes **5 files changed** (+116 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `internal/docker/container.go` (+22 -20) 📝 `internal/docker/idlewatcher/types/config.go` (+33 -10) ➕ `internal/docker/idlewatcher/types/config_test.go` (+47 -0) 📝 `internal/docker/idlewatcher/waker_http.go` (+6 -0) 📝 `internal/docker/labels.go` (+8 -7) </details> ### 📄 Description Optionally allow a user to specify a “warm-up” endpoint to start the container, returning a 403 if the endpoint isn’t hit and the container has been stopped. This can help prevent bots from starting random containers, or allow health check systems to run some probes. Or potentially lock the start endpoints behind a different authentication mechanism, etc. Sample service showing this: ```yaml hello-world: image: nginxdemos/hello container_name: hello-world restart: "no" ports: - "9100:80" labels: proxy.aliases: hello-world proxy.#1.port: 9100 proxy.idle_timeout: 45s proxy.wake_timeout: 30s proxy.stop_method: stop proxy.stop_timeout: 10s proxy.stop_signal: SIGTERM proxy.start_endpoint: "/start" ``` Hitting `/` on this service when the container is down: ```curl $ curl -sv -X GET -H "Host: hello-world.godoxy.local" http://localhost/ * Host localhost:80 was resolved. * IPv6: ::1 * IPv4: 127.0.0.1 * Trying [::1]:80... * Connected to localhost (::1) port 80 > GET / HTTP/1.1 > Host: hello-world.godoxy.local > User-Agent: curl/8.7.1 > Accept: */* > * Request completely sent off < HTTP/1.1 403 Forbidden < Content-Type: text/plain; charset=utf-8 < X-Content-Type-Options: nosniff < Date: Wed, 08 Jan 2025 02:04:51 GMT < Content-Length: 71 < Forbidden: Container can only be started via configured start endpoint * Connection #0 to host localhost left intact ``` Hitting `/start` when the container is down: ```curl curl -sv -X GET -H "Host: hello-world.godoxy.local" -H "X-Goproxy-Check-Redirect: skip" http://localhost/start * Host localhost:80 was resolved. * IPv6: ::1 * IPv4: 127.0.0.1 * Trying [::1]:80... * Connected to localhost (::1) port 80 > GET /start HTTP/1.1 > Host: hello-world.godoxy.local > User-Agent: curl/8.7.1 > Accept: */* > X-Goproxy-Check-Redirect: skip > * Request completely sent off < HTTP/1.1 200 OK < Date: Wed, 08 Jan 2025 02:13:39 GMT < Content-Length: 0 < * Connection #0 to host localhost left intact ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 14:25:39 +01:00
adam closed this issue 2025-12-29 14:25:39 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/godoxy-yusing#144