hysteria icon indicating copy to clipboard operation
hysteria copied to clipboard

acme非标端口申请证书

Open ypxun opened this issue 8 months ago • 11 comments

不是bug,只是不知道使用什么分类的issue,就默认用这个了,不好意思。 因为nginx占用80和443端口的原因,hy2的acme使用80和443端口自动申请证书总是不太方便。我参照 #804 ,将

location /.well-known/acme-challenge {
    proxy_set_header Host $host;
    proxy_set_header X-Real_IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
    proxy_pass http://127.0.0.1:8080;
}

填入nginx.conf,但报错,主要错误是在 HTTP-01 挑战过程中,ACME 服务从 a.a.com 获取到的响应无效,通常是由于挑战响应文件无法正确访问: ERROR acme_client challenge failed {"identifier": "a.a.com", "challenge_type": "http-01", "problem": {"type": "urn:ietf:params:acme:error:unauthorized", "title": "", "detail": "1.2.3.4: Invalid response from https://a.a.com/.well-known/acme-challenge/YDqLJyBn-IOHaopgXCG7tzJFQ9sRymS5za6N1gwTiYU: \"<!DOCTYPE html>\\n<html lang=\\\"en\\\" translate=\\\"no\\\">\\n <head>\\n \\n <meta charset=\\\"utf-8\\\" >\\n <meta name=\\\"viewport\\\" content=\\\"wid\"", "instance": "", "subproblems": []}} 然后我又尝试在hy2的config.yaml acme部分填入 altHTTPPort: 8080,还是不行,一样是响应文件不对。 我在nginx.conf里的默认80 server块设置:

    server {
        listen 80;
        listen [::]:80;

        location /.well-known/ {
            root /var/www/html;
        }

        # acme验证
        location /.well-known/acme-challenge/ {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:8080;
        }

        location / {
            rewrite ^(.*)$ https://$host$1 permanent;
        }
    }
}


想问下,我设置到底错在哪,导致acme不能自动使用非标端口申请证书?

ypxun avatar Jun 21 '24 15:06 ypxun