如何在uWSGI中以logformat添加HTTP_FORWARDED

dev*_*v ツ 2 python uwsgi falconframework

我指的是 - https://uwsgi-docs.readthedocs.io/en/latest/LogFormat.html

默认日志格式为:

[pid: %(pid)|app: -|req: -/-] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) %(uri) => generated %(rsize) bytes in %(msecs) msecs (%(proto) %(status)) %(headers) headers in %(hsize) bytes (%(switches) switches on core %(core))
Run Code Online (Sandbox Code Playgroud)

%(addr)REMOTE_ADDR

我的应用程序位于一个反向代理后面。所以我需要HTTP_FORWARDED获取客户端的真实IP地址。

我可以看到配置用户定义的日志变量的选项,但不确定是否可以通过Falcon实现。

Evh*_*vhz 8

将选项添加--log-x-forwarded-for到 uwsgi 命令,或者
添加到site.ini ,如下所示:

log-x-forwarded-for = true
Run Code Online (Sandbox Code Playgroud)

如果您使用配置文件。

请参阅 uwsgi选项中的详细信息