Command I run Caddy with: caddy start (or caddy reload afterwards)
I use Caddy as a reverse_proxy for OshiUpload file upload service. It works from web browser UI (file uploading, file downloading, file removing) and also works with HTTPS; no issues. However, main idea behind Oshi is to use it from CLI with curl, like: curl -T yourfile.txt https://domain.com and then you get a download link in return.
I’ve made this Caddyfile:
First one is the “Web-UI” and it works OK. Second one is the “curl -T” interface (which does CURL PUT request). The request always fails with 502:
< HTTP/2 502
So, can I tell Caddy to forward files that was PUT into it without changing the PUT request to localhost:4020? How could I achieve this?
a. System environment:
Bedrock Linux 0.7.23 Poki on top of Debian 9 with systemd
b. Command:
caddy start
c. Service/unit/compose file:
This is oshi config file, the part with ports in use
# HTTP main app & POST uploads listen address and port, * for listening on all interfaces
HTTP_APP_ADDRESS = *
HTTP_APP_PORT = 4019
# HTTP PUT uploads listen address and port
HTTP_PUT_ADDRESS = ::
HTTP_PUT_PORT = 4020
I use Caddy as a reverse_proxy for OshiUpload file upload service. It works from web browser UI (file uploading, file downloading, file removing) and also works with HTTPS; no issues. However, main idea behind Oshi is to use it from CLI with curl, like: curl -T yourfile.txt https://domain.com and then you get a download link in return.
4. Error messages and/or full log output:
< HTTP/2 502
5. What I already tried:
Changing from HTTPS to HTTP with http:// and :80 adding into Caddyfile
Try running with caddy run instead of caddy start, so that you can see the logs.
Running with caddy start is not recommended for a permanent server, because it won’t restart automatically when the machine boots. Please run Caddy as a system service instead.
2021/08/28 03:26:13.594 INFO using adjacent Caddyfile
2021/08/28 03:26:13.612 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2021/08/28 03:26:13.613 INFO http server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2021/08/28 03:26:13.613 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000426af0"}
2021/08/28 03:26:13.613 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2021/08/28 03:26:13.614 INFO http enabling automatic TLS certificate management {"domains": ["cl.aim.us.to", "aim.us.to"]}
2021/08/28 03:26:13.614 INFO tls cleaning storage unit {"description": "FileStorage:/root/.local/share/caddy"}
2021/08/28 03:26:13.619 INFO tls finished cleaning storage units
2021/08/28 03:26:13.641 INFO autosaved config (load with --resume flag) {"file": "/root/.local/share/caddy/autosave.json"}
2021/08/28 03:26:13.642 INFO serving initial configuration
About running; I will move Caddy to systemctl service after I understand if it can be used for curl PUT transfers. Thanks for advices.
# HTTP PUT uploads listen address and port
#HTTP_PUT_ADDRESS = :: - this one I commented out and put this instead:
HTTP_PUT_ADDRESS = *
HTTP_PUT_PORT = 4020
Now, when I do:
(base) [sm@fedora-mbp test]$ curl -T testfile -vvvv https://cl.aim.us.to
* Trying 162.248.160.11:443...
* connect to 162.248.160.11 port 443 failed: Connection refused
(base) [sm@fedora-mbp test]$ curl -T testfile -vvvv cl.aim.us.to
* connect to 162.248.160.11 port 80 failed: Connection refused
Finally, if I do it with a port:
curl -T testfile -vvvv cl.aim.us.to:4020
It works OK. The thing is, I was thing to bind cl.* subdomain to port 4020 via Caddy.