如何使用golang lego让我们加密nginx后面的客户端? [英] How to use golang lego let's encrypt client behind nginx?

查看:175
本文介绍了如何使用golang lego让我们加密nginx后面的客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置让我们使用nginx将证书加密到服务器上,使用Go中写入的lego客户端 https: //github.com/xenolf/lego/



我会用nginx config取得证书吗?


您需要在以下位置添加:80和443虚拟服务器:

 

#http和https nginx服务器
位置/.well-known/acme-challenge/ {
proxy_set_header Host $ host;
proxy_pass http://127.0.0.1:4000$request_uri;
}

并运行lego二进制文件:

  ./ lego.amd64 --http 127.0.0.1:4000 --email =your@address.tld--domain domain.tld --domain some.domain。 tld run 

您的证书文件储存在:

 #ls -la .lego / certificates / 
total 20
drwx ------ 2 root root 4096 Nov 9 08:06。
drwx ------ 4根root 4096 Nov 9 08:06 ..
-rw ------- 1 root root 3477 Nov 9 08:15 domain.tld.crt
-rw ------- 1 root root 226 Nov 9 08:15 domain.tld.json
-rw ------- 1 root root 1679 Nov 9 08:15 domain。 tld.key

如果nginx已经使用了有效的SSL / TLS证书,并且您想添加新的域名您需要排除的证书中的姓名 tls-sni-01 求解器:

  ./ lego.amd64 --exclude = tls-sni-01 --http 127.0.0.1:4000 --email =your@address.com--domains domain.tld --domains new.domain.tld run 


I'd like to setup Let's Encrypt certificate to live server with nginx with lego client written in Go https://github.com/xenolf/lego/

What I'll to do with nginx config to get certificate?

解决方案

You need to add in :80 and :443 virtual servers following location:

# http and https nginx servers
location /.well-known/acme-challenge/ {
    proxy_set_header Host $host;
    proxy_pass http://127.0.0.1:4000$request_uri;
}

And run lego binary:

./lego.amd64 --http 127.0.0.1:4000 --email="your@address.tld" --domains domain.tld --domains some.domain.tld run

Your certificate files stored in:

# ls -la .lego/certificates/
total 20
drwx------ 2 root root 4096 Nov  9 08:06 .
drwx------ 4 root root 4096 Nov  9 08:06 ..
-rw------- 1 root root 3477 Nov  9 08:15 domain.tld.crt
-rw------- 1 root root  226 Nov  9 08:15 domain.tld.json
-rw------- 1 root root 1679 Nov  9 08:15 domain.tld.key

In case nginx already works with valid SSL/TLS certificate and you want to add new domain name in certificate you need to exclude tls-sni-01 solver:

./lego.amd64 --exclude=tls-sni-01  --http 127.0.0.1:4000  --email="your@address.com" --domains domain.tld --domains new.domain.tld run

这篇关于如何使用golang lego让我们加密nginx后面的客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆