【发布时间】:2021-11-23 21:31:18
【问题描述】:
我正在尝试从环境变量中为 Dockerised 反向代理设置 Nginx ssl 服务器值,这样我就可以避免配置多个文件。
我遇到的问题是 Nginx 要么不识别环境变量,要么给我语法错误,说明我没有用 ; 终止该行。
这是我得到的错误:
nginx_1 | nginx: [emerg] directive "ssl_certificate" is not terminated by ";" in /etc/nginx/conf.d/default.conf:10
我的ngnx.conf
server {
listen 443 ssl;
listen [::]:443 ssl;
include /etc/nginx/snippets/ssl-params.conf;
server_name website.com www.website.com;
access_log /vol/log/nginx/website.access.log;
error_log /vol/log/nginx/website.error.log;
ssl_certificate /etc/ssl/$ENV{FULLCHAIN} ;
ssl_certificate_key /etc/ssl/$ENV{PRIVKEY} ;
location /static {
alias /vol/static;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://app:5000/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
client_max_body_size 10M;
}
}
我也尝试了以下变体,但似乎没有什么是有效的:
/etc/ssl/$ENV{FULLCHAIN} /etc/ssl/$FULLCHAIN /etc/ssl/"$ENV{FULLCHAIN}"
我已经检查了环境变量是 sh 并且它们存在,只有 Nginx 看不到它们。
这样做的正确方法是什么,或者我最好在构建时做一些 bash fu 来编辑?
【问题讨论】:
标签: nginx