简体   繁体   English

带球童的HTTPS代理

[英]HTTPS proxy with caddy

I am working with a Golang app and Caddy as the HTTP server. 我正在使用Golang应用程序和Caddy作为HTTP服务器。 The golang app rejects every http connection, it only can be used over HTTPS. golang应用程序拒绝每个HTTP连接,只能在HTTPS上使用。 This app is a kind of API/service that is consumed by other apps. 此应用程序是其他应用程序使用的一种API /服务。 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. 因为它需要HTTPS,所以我安装了Caddy,因此我可以利用自动SSL证书并使用代理在端口之间进行切换。

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. 该应用程序在端口9000上运行,因此,使用者只会写mysite.com而caddy应该负责将请求重定向到端口9000的重定向,但仍保持HTTPS。 The configuration in caddy for the site is: 该站点在caddy中的配置为:

mysite.com {
    proxy / :9000 {
        max_fails 1
    }
    log logfile
}

Nevertheless, it seems like when the proxy is made the HTTPS is lost. 但是,似乎在制作代理后,HTTPS丢失了。 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. 因此,基于此错误,对我来说,caddy制作的HTTP代理似乎丢失了HTTPS。 What can I do? 我能做什么?

From the caddy docs 来自球童文档

to is the destination endpoint to proxy to. to是要代理的目标端点。 At least one is required, but multiple may be specified. 至少需要一个,但可以指定多个。 If a scheme (http/https) is not specified, http is used. 如果未指定方案(http / https),则使用http。 Unix sockets may also be used by prefixing "unix:". Unix套接字也可以通过在前缀“ unix:”之前使用。

So maybe it is sending http requests to the proxied https endpoint. 因此,也许它将HTTP请求发送到代理的https端点。

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. 在这种情况下,您可能不一定严格要求:9000上的应用程序监听https。 It may simplify your deployment or cert management to just have it listen http and have caddy manage all the certs. 它可以简化您的部署或证书管理,使其仅监听HTTP并让Caddy管理所有证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM