赞
踩
nginx.conf中添加配置
proxy_set_header X-Real-IP $remote_addr;
- server {
-
- listen 8000;
-
- proxy_set_header X-Real-IP $remote_addr;
-
- 。。。
代码中即可获取IP
- std::string ip = "";
-
- auto realIp = req.headers.find("X-Real-IP");
- if (realIp != req.headers.end())
- {
- ip = realIp->second;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。