【发布时间】:2019-01-21 20:15:59
【问题描述】:
我遇到了与此问题中所述相同的问题:How to not log a get request parameter in the nginx access logs?
但是,由于 nginx 是通过 AWS 配置的,所以我在部署时不确定如何修改它。我不清楚这些配置的去向。 AWS 支持无法提供帮助,因为这是 nginx 而不是 AWS 的问题。
任何能指引我正确方向的信息将不胜感激。
到目前为止,我所拥有的只是我可以在我部署到 EB 的存储库中修改 ./ebextensions/nginx.config,但其中需要设置的内容尚不清楚。
==================================
好的,所以一些有趣的更新。基本上,AWS EB 环境为其实例设置了默认的 nginx.configs。在这些配置中,它包括某个路径中的所有 *.config 文件,包括一个包含服务器指令的自动生成文件。它将所有这些注入到 nginx.config 的 http 指令中。
您确实可以选择完全覆盖 nginx 配置。但是,作为一个对那里发生的一切以及这样做的潜在危险几乎一无所知的人,我认为最好不要尽可能地修改默认行为。因此,我决定找到一种方法来修改这个自动生成的 .config 文件并重新启动 nginx。
到目前为止,我的./ebextensions/01_proxy.config:
files:
"/etc/nginx/conf.d/injectObfuscation.sh":
content: |
# This script expects a file as input with an nginx server directive to be injected into the http directive of an nginx.config file.
# It will make two modifications:
# - It will create a log_format to be used when filtering the password parameter
# - It will find the server directive and inject a location directive for the sensitive endpoint
# - This directive will replace the sensitive parameter with *s and use the filter log_format instead of the main log_format
# TODO: Figure out how to do the above ^^
container_commands:
01_update_server_directive:
command: "./etc/nginx/conf.d/injectObfuscation.sh /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf"
02_reload_nginx:
command: "sudo service nginx reload"
files: 行声明我正在创建一些文件以添加到 EC2 实例。在这里,我的目标是创建一个 bash 脚本来完成我的任务。正如 cmets 中所述,我的任务是首先添加一行带有 log_format 的行。然后,找到带有server{ 的行,在它下面我需要完整地注入locations /my/sensitive/endpoint 指令。
如果对编写这个我完全不熟悉的 bash 脚本有任何帮助,我们将不胜感激。
【问题讨论】:
标签: amazon-web-services nginx ebextensions