gpt4 book ai didi

docker - 如何为 ssl_certificate 动态设置域

转载 作者:行者123 更新时间:2023-12-02 18:46:25 28 4
gpt4 key购买 nike

我通过openresty使用lua并设置环境变量来动态设置域名。我有:

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;
}

env MYDOMAIN;

http {
server {
listen 80;
listen 443 ssl;
set_by_lua $MYDOMAIN 'return os.getenv("MYDOMAIN")';
server_name $MYDOMAIN www.$MYDOMAIN;
location / {
proxy_pass http://127.0.0.1:5000;
index index.html index.htm;
}
ssl_certificate /etc/letsencrypt/live/$MYDOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/$MYDOMAIN/privkey.pem;
}
}

我收到一个错误:
nginx: [emerg] BIO_new_file("/etc/letsencrypt/live/$MYDOMAIN/fullchain.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/$MYDOMAIN/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

设置 server_name 可以正常工作,但在 ssl_certificate 和 ssl_certificate_key 的情况下,它实际上是采用 $MYDOMAIN 的值。

最佳答案

Nginx 1.15.9 版支持“ssl_certificate”和“ssl_certificate_key”指令中的变量。

关于docker - 如何为 ssl_certificate 动态设置域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50997696/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com