- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个非常简单的基于 golang 的 API,它只监听路径并相应地响应数据库插入。
我想使用 Lets Encrypt 通过 TLS/https 提供服务,但所有教程似乎都表明需要使用 Apache 或 nginx。
我喜欢让我的服务器保持真正的轻量级并且没有看到任何需要引入这些网络服务器的开销(它绝对不是一个完整的网站)并且通过 http 我的 go 实现运行良好。
没有Apache或者nginx可以安装吗?
最佳答案
不,您不需要使用 Apache/Nginx,Go 可以很好地处理 TLS。
例子:
➜ sudo letsencrypt certonly --standalone --agree-tos --email you@email.com -d domain1.com [-d domain2.com, etc..]
➜ sudo cat /etc/letsencrypt/archive/domain1.com/fullchain1.pem > cert.pem
➜ sudo cat /etc/letsencrypt/archive/domain1.com/privkey1.pem > key.pem
➜ cat main.go
import (
"log"
"net/http"
)
func handler(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.Write([]byte("This is an example server.\n"))
}
func main() {
http.HandleFunc("/", handler)
log.Printf("About to listen on 10443. Go to https://domain1.com:10443/")
log.Fatal(http.ListenAndServeTLS(":10443", "cert.pem", "key.pem", nil))
}
请注意,如果您希望您的 go 服务器监听端口 443(默认 https 端口),您必须以 root 身份运行它或使用 systemd 将端口传递给它。
443端口运行示例:
将代码更改为 log.Fatal(http.ListenAndServeTLS(":443", "cert.pem", "key.pem", nil))
开始构建
sudo ./your-package-name
setcap cap_net_bind_service=+ep your-package-name
然后您将能够以用户身份收听端口 443/80。有关使用 setcap 的更多详细信息:https://wiki.apache.org/httpd/NonRootPortBinding
关于apache - 我需要使用 nginx 或 Apache 才能使用 Lets Encrypt 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36873304/
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 8 年前。 Improve this ques
我heard “PKCS#1 v2.0 加密通常称为 OAEP 加密”。 在我的项目中使用它之前,我需要某种“官方”文档来说明这一点。我试图找到它但没有成功。知道在哪里可以找到吗? 谢谢! (顺便说一
已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 来自:加密公司 收件人:x$*sj4(就是你) 如果您选择接受的话,您的任务是用最短的击键次数
我正在使用带有 docker/docker compose 和 traefik 的 ubuntu 18.04.1 LTS。使用暂存 Let's Encrypt caserver ( https://a
我目前正在完成一篇关于通过各种密码算法加密数据的论文。 我花了很多时间阅读期刊和论文,但还没有找到任何关于它们的性能复杂性的记录。 有人知道以下算法的 Big-O 复杂度吗? RSA DES 三重 D
我正在为嵌入式系统(微 Controller )编写固件。固件可以通过引导加载程序(也是我编写的)进行更新。 现在需要采取措施防止固件被操纵,因此系统必须仅执行具有某种有效签名的下载固件。 固件文件已
我试图了解加密(“受密码保护”)Office 2007 文档(特别是 Excel 文档)的捆绑方式。我正在试验一个已知的、受密码保护的电子表格。 当我解压 XLSX 文件时,我遇到了三个条目: [6]
K8s对encrypt secret data具有此功能,这需要修改kube-apiserver配置,我如何在GKE中做到这一点? 最佳答案 简短的答案是,你不能。 Kubernetes Engine
我正在使用 ENCRYPT() 函数在 mysql 中存储一个字符串。我想获取匹配该字符串的行,但新的 ENCRYPT() 调用给了我一个不同的值,因此它们永远不会匹配。 这是预期的,因为我没有(也不
在带有 Python 2.7 和 GPG4Win v2.2.0 的 Windows 7 上使用 python-gnupg v0.3.5 test_gnupg.py 导致 2 次失败: Test tha
我尝试兼容 C# 和 Java 的加密/解密。 据我所知,默认模式在 Java 中是“ecb/pkcs5”,在 C# 中是“cbc/pkcs7”。 所以我匹配这些东西。 第一个问题是 PKCS7 和
我使用 SwiftyRSA 使用带有 PKCS1 填充的公钥加密字符串。不幸的是,当我用 Java 解密我的加密字符串时,我发现了 BadPadding: Encryption Error。到目前
比特币是一种匿名的加密数字货币。几个月前我有了加密文件的想法,其中需要比特币的支出证明才能解密文件。当比特币被发送到给定地址时,它会显示在分布在对等网络中的块文件中。区块链的完整性是通过需要大量计算机
我有一个类,我试图用依赖注入(inject)替换 Crypt::encrypt 的外观用法: encrypter= $encrypter; }
我想使用带有 RSA 算法的 OpenSSL 使用私钥加密文件: openssl rsautl -in txt.txt -out txt2.txt -inkey private.pem -encryp
我在 TCL 中使用 DES 来加密一些短语,我想将这些加密的短语存储在一些我需要轻松操作的 ascii 文件中。因此,我希望“加密短语”仅由标准 ascii 字符构成(最好没有空格)。 我正在使用类
我在 TCL 中使用 DES 来加密一些短语,我想将这些加密的短语存储在一些我需要轻松操作的 ascii 文件中。因此,我希望“加密短语”仅由标准 ascii 字符构成(最好没有空格)。 我正在使用类
我对Android平台不同的数据存储加密机制有点困惑。据我了解: 全盘加密影响整个/data 磁盘并且只能是由用户激活/停用。 ( https://source.android.com/securit
我正在使用 Lumberjack 作为日志记录平台(Objective C/Swift)有没有办法将日志加密写入文件? 如果是,那么任何例子都是有用的 另外,之后如何读取加密后的日志 密集型日志记录是
我确定这是一个典型的场景,但我找不到合适的步骤顺序。 我有一个运行 Apache 的 www.example.com 服务器(比如)1.1.1.1。我正在使用 Caddy 在 2.2.2.2 上构建一
我是一名优秀的程序员,十分优秀!