[英]How can I get the remote IP / Client IP using NGINX in Docker ?? Also using Laravel
[英]How to get client ip from request using symfony in docker
我尝试使用以下方法获取 ip:
$request->getClientIp()
返回:
172.30.0.1
而不是210.110.98.180
在 docker-compose 中使用这样的东西
http:
build:
context: .
dockerfile: ./Dockerfile
volumes:
- "./:/var/www/http/"
ports:
- "80:80"
通过将其添加到 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.