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 摘要。