英文:
HTTPS proxy with caddy
问题
我正在使用Golang应用程序和Caddy作为HTTP服务器。Golang应用程序拒绝每个HTTP连接,只能通过HTTPS使用。这个应用程序是一种被其他应用程序使用的API/服务。因为它需要HTTPS,所以我安装了Caddy,这样我就可以利用自动SSL证书并使用代理在端口之间切换。
应用程序在9000端口运行,所以消费者只需写入mysite.com
,Caddy应该负责将这些请求重定向到9000端口,同时保持HTTPS。Caddy的站点配置如下:
mysite.com {
proxy / :9000 {
max_fails 1
}
log logfile
}
然而,似乎在进行代理时丢失了HTTPS。我检查了应用程序的日志(而不是Caddy的日志),我得到了以下错误信息:
http: TLS handshake error from xxx.xxx.xxx.xxx:xxxx: tls: oversized record received with length 21536
根据这个错误,我认为Caddy所做的HTTP代理丢失了HTTPS。我该怎么办?
英文:
I am working with a Golang app and Caddy as the HTTP server. The golang app rejects every http connection, it only can be used over HTTPS. This app is a kind of API/service that is consumed by other apps. As, it requires HTTPS I installed Caddy so I can take advantage of the automatic SSL certificate and use proxy to switch between the ports.
The application is running in the port 9000, so, the consumers will only writte mysite.com
and caddy should be in charge of redirect that petitions to the port 9000 but maintaining the HTTPS. The configuration in caddy for the site is:
mysite.com {
proxy / :9000 {
max_fails 1
}
log logfile
}
Nevertheless, it seems like when the proxy is made the HTTPS is lost. I checked the logs for the application (no the logs of caddy) and I get this:
http: TLS handshake error from xxx.xxx.xxx.xxx:xxxx: tls: oversized record received with length 21536
So, based in this error, to me looks like the HTTP proxy made by caddy is losing the HTTPS. What can I do?
答案1
得分: 5
从caddy文档中可以看到:
> to 是要代理到的目标终点。至少需要指定一个,但可以指定多个。如果未指定方案(http/https),则默认使用http。也可以通过前缀"unix:"来使用Unix套接字。
所以也许它正在将http请求发送到代理的https终点。
是否可以通过以下配置来解决问题?
mysite.com {
proxy / https://localhost:9000 {
max_fails 1
}
log logfile
}
如果是这种情况,你可能不需要在:9000上监听https。只需让应用程序监听http,并让caddy管理所有证书,这可能会简化部署或证书管理。
英文:
From the caddy docs
> to is the destination endpoint to proxy to. At least one is required,
> but multiple may be specified. If a scheme (http/https) is not
> specified, http is used. Unix sockets may also be used by prefixing
> "unix:".
So maybe it is sending http requests to the proxied https endpoint.
Does
mysite.com {
proxy / https://localhost:9000 {
max_fails 1
}
log logfile
}
fix it?
If that is the case, you may not strictly need your app on :9000 to listen https. It may simplify your deployment or cert management to just have it listen http and have caddy manage all the certs.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论