简体   繁体   English

How can i get the client IP address in Flask running on an Azure Linux Web App?

[英]How can i get the client IP address in Flask running on an Azure Linux Web App?

I am running a flask site on an Azure Linux Web App.我在 Azure Linux ZC6E190B2854633C48EZEZDA9 应用程序上运行 flask 站点。 I've come to a point where I need to know the client ip address.我已经到了需要知道客户端 ip 地址的地步。 I have read many threads that talk about accessing the client IP address when behind a proxy and that you must update your nginx configuration file to pass this information through the proxy, however, I don't think my Azure Linux web app is running an nginx web server. I have read many threads that talk about accessing the client IP address when behind a proxy and that you must update your nginx configuration file to pass this information through the proxy, however, I don't think my Azure Linux web app is running an nginx web 服务器。

How can I tell which web server my Azure Linux Web App is running and how can I start to look for the client IP address in the python code of my Flask app? How can I tell which web server my Azure Linux Web App is running and how can I start to look for the client IP address in the python code of my Flask app?

In Azure Linux Web App, it will change the request from the Internet through the reverse proxy.在Azure Linux Web App中,它会通过反向代理改变来自互联网的请求。 So you need to use the request package to get the client.所以需要使用request package来获取客户端。 The example code here:这里的示例代码:

clinet_ips = request.headers.getlist("X-Forwarded-For")

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

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