繁体   English   中英

如何隐藏 nginx.conf 授权凭据?

[英]How to hide nginx.conf authorization credentials?

为了快速解释,我有一个 nginx 服务器在 Docker 中运行,充当我的 Flask Z2567CDZ840EC9705EB7AC23 的反向代理。 我的配置的一部分是使用proxy_set_header Authorization将一些凭据传递到proxy_pass网站。

这一切都很好 - 但是,我想将所有这些东西推送到 GitHub,当然不希望我的凭据(无论是否编码)出现。

我在这里最好的选择是什么? 我能想到的只是有类似于 dotenv 的东西,但对于 nginx.conf 文件而不是 .py 文件。

有没有人知道我可以做些什么来传递我的信用没有在配置中明确地硬编码它们?

您可以使用另一个配置文件使用set创建具有 NGINX 的变量并将此文件添加到 gitignore。

conf.d/creds.include

set $apiuser "user";
set $apipass "pass";

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#set

应用程序配置文件

server {
include conf.d/creds.include;
...
location / {
  proxy_pass ...
  proxy_set_header "Authorization: $apiuser:apipass"
}
}

你应该在你的仓库的自述文件中提到这一点,任何人都知道如何使用它。

暂无
暂无

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

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