[英]How to get client ip from request using symfony in docker
I try to get the ip using:我尝试使用以下方法获取 ip:
$request->getClientIp()
Which returns:返回:
172.30.0.1
instead of something like 210.110.98.180
172.30.0.1
而不是210.110.98.180
Using this something like this in docker-compose在 docker-compose 中使用这样的东西
http:
build:
context: .
dockerfile: ./Dockerfile
volumes:
- "./:/var/www/http/"
ports:
- "80:80"
Fixed it by adding it to a docker network.通过将其添加到 docker 网络来修复它。
http:
build:
context: .
dockerfile: ./Dockerfile
volumes:
- "./:/var/www/http/"
ports:
- "80:80"
networks:
- bridge2
networks:
bridge2:
external: true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.