abiosoft / abiosoft/caddy-exec

Input query/post data and return script stdout in response?

未關閉
#7 3 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Go
星號
155
分支
21
PR 合併指標
30 天內沒有已合併 PR

描述

Hello, and thanks so much for this great module. <3

I have looked for caddy-exec related issues and in the caddy documentation to see if I am missing something. But now I come to you, my last hope. :-)

## My setup:

I'm building a caddy image with caddy-exec and [caddy-hmac](https://github.com/abiosoft/caddy-hmac) like so:

`$PWD\docker-compose.yml`
```yaml
version: "3.7"

services:
caddy:
build:
context: .
dockerfile: $PWD/config/caddy/caddy.Dockerfile
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
env_file:
- $PWD/config/secrets/local.env
volumes:
- $PWD/config/caddy/Caddyfile:/etc/caddy/Caddyfile
- $PWD/site:/site
- $PWD/api:/api
- caddy_data:/data
- caddy_config:/config

volumes:
caddy_data:
caddy_config:
```

My `$PWD/config/secrets/local.env` file:
```env
# Use localhost for local or an IP or Domain
SITE_ADDRESS=localhost

# API key
API_KEY=abcde123456
```

`$PWD/config/caddy/caddy.Dockerfile`
```Dockerfile
FROM caddy:2.2.1-builder-alpine AS builder

RUN xcaddy build v2.2.1 \
--with github.com/abiosoft/caddy-exec \
--with github.com/abiosoft/caddy-hmac

FROM caddy:2.2.1-alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy

# Install python3
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache \
python3 && ln -sf /bin/python3 /usr/bin/python
```

And my `$PWD/config/caddy/Caddyfile`:
```Caddyfile

{$SITE_ADDRESS} {

root / /site/index.html
header Content-type application/json
file_server

# API Routes

route /api/example/python {
exec {
command /usr/bin/python3
args \
/api/example/python/python-example.py \
{$API_KEY} \
{query}
directory /api/example/python
timeout 5s
foreground
}
}
}
```

## My issue(s):

1.- So far I can pass my env vars to the scripts (not only python, but bash and other unforeseen languages), but the {query} shows up in the logs as {http.request.uri.query}, and not the intended string.

2.- Then I only see a JSON response giving a `success` status, or `error` status, but I do not see how to pass my scripts output to the response.

Any insight about something that I'm obviously missing is appreciated. And thank you again for the support, documentation and development you have provided so far.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。