简体   繁体   English

letsencrypt django webroot

[英]letsencrypt django webroot

I am trying to setup my nginx and django to be able to renew certificates. 我正在尝试设置我的nginx和django以便能够续订证书。 However something goes wrong with my webroot-plugin 但是我的webroot-plugin出了问题

in nginx: 在nginx中:

location ~ /.well-known {
    allow all;
}

But when I run the renewal command: 但是当我运行续订命令时:

./letsencrypt-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=/home/sult/huppels -d huppels.nl -d www.huppels.nl

However it seems that the cert renewal wants to retrieve a file from my server cause i get the following error. 但是,似乎证书续订想要从我的服务器检索文件,因为我得到以下错误。

The following errors were reported by the server: 服务器报告了以下错误:

Failed authorization procedure. 授权程序失败。 www.huppels.nl (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.huppels.nl/.well-known/acme-challenge/some_long_hash [51.254.101.239]: 400 www.huppels.nl(http-01):urn:acme:错误:unauthorized ::客户端缺乏足够的授权::来自http://www.huppels.nl/.well-known/acme-challenge/some_long_hash的响应无效[51.254.101.239]:400

How do i make this possible with nginx or django? 如何使用nginx或django实现这一目标?

I have my Django app running with gunicorn. 我有我的Django应用程序与gunicorn运行。 I followed the instructions here . 我按照这里的说明操作。

I made sure to include the proper location blocks: 我确保包含正确的位置块:

location /static  {
    alias /home/user/webapp;
}

location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Making sure to include any template location alias as well. 确保包含任何模板位置别名。

I set the .well-known location block like this; 我像这样设置了.well已知的位置块;

location /.well-known {
    alias /home/user/webapp/.well-known;
}

Pointing it directly do the root of the webapp instead of using the allow all. 指向它直接执行webapp的根,而不是使用allow all。

I did have to make sure that I only used the non ssl block until the certificate was generated then I used a different nginx config based on h5bps nginx configs. 我必须确保在生成证书之前我只使用了非ssl块然后我使用了基于h5bps nginx配置的不同nginx配置。

Note: Make sure you have proper A records for you domain pointing to www if you are going to use h5bp to redirect to www. 注意:如果您要使用h5bp重定向到www,请确保您的域名指向适当的A记录。

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

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