dongyuchen9276 2016-11-09 08:51
浏览 70
已采纳

如何使用golang lego让我们在nginx后面加密客户端?

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?

  • 写回答

1条回答 默认 最新

  • doudi2229 2016-11-09 08:51
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退