我遇到了与此问题中所述相同的问题:如何不在 nginx 访问日志中记录获取请求参数?
但是,由于 nginx 是通过 AWS 配置的,所以我在部署时不确定如何修改它。我不清楚这些配置的去向。AWS 支持无法提供帮助,因为这是 nginx 而不是 AWS 的问题。
任何可以为我指明正确方向的信息将不胜感激。
到目前为止,我所拥有的只是我可以./ebextensions/nginx.config
在部署到 EB 的存储库中进行修改,但其中需要设置的内容尚不清楚。
==================================
好的,所以一些有趣的更新。基本上,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 脚本来完成我的任务。如评论中所述,我的任务是首先使用 log_format 添加一行。然后,找到带有 的行server{
,在它下面我需要locations /my/sensitive/endpoint
完整地注入指令。
对于编写这个我完全不熟悉的 bash 脚本的任何帮助,将不胜感激。