【问题标题】:How do I log what nginx sends to the proxy with proxy_pass?如何使用 proxy_pass 记录 nginx 发送到代理的内容?
【发布时间】:2020-02-08 00:42:20
【问题描述】:

我有一个扇出 nginx 配置,其中包含在不同端口上运行的一堆服务。

当通过 nginx 访问服务时,我很难让服务按预期运行;它们在本地命中时表现如预期。

如何准确查看传递给代理的 URI/URL?

nginx 配置的相关位如下:

    location ~ ^/auth/(.*)$ {
            #proxy_set_header Host api.flourishzone.uk/auth/ ;
            proxy_set_header Host $host;
            add_header X-debug-message "URI  ${request_uri}";
            add_header X-debug-message "URI passed thru ${uri}";
            proxy_pass http://127.0.0.1:8080/auth/$1;
    }

【问题讨论】:

  • 查看远程服务器的访问日志。向我们展示您的 nginx 配置,以便我们查看是否有任何重写规则或任何修改请求的内容。另请检查this,未标记为已接受的答案向您展示了如何在 nginx 和远程之间设置某些日志的好方法。希望对您有所帮助。

标签: nginx


【解决方案1】:

在 nginx 配置文件中添加 upstreamlogaccess_log。然后用nginx -t测试,然后用nginx -s reload重新加载,setting-up-the-access-log

http {
    log_format compression '$remote_addr - $remote_user [$time_local] '
                           '"$request" $status $body_bytes_sent '
                           '"$http_referer" "$http_user_agent" "$gzip_ratio"';

    server {
        gzip on;
        access_log /spool/logs/nginx-access.log compression;
        ...
    }
}

【讨论】:

  • upstreamlog 没有找到——你有参考吗?
猜你喜欢
  • 2016-12-22
  • 2019-03-20
  • 2018-07-01
  • 2015-05-29
  • 1970-01-01
  • 2023-03-12
  • 1970-01-01
  • 2019-12-22
  • 2018-07-08
相关资源
最近更新 更多