如何在docker中使用symfony从请求中获取客户端IP

时间:2020-10-06 15:23:52

标签: php docker symfony ip

我尝试使用以下方法获取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"

1 个答案:

答案 0 :(得分:0)

通过将其添加到 docker 网络来修复它。

http:
    build:
      context: .
      dockerfile: ./Dockerfile
    volumes:
      - "./:/var/www/http/"
    ports:
      - "80:80"
    networks:
      - bridge2

networks:
  bridge2:
    external: true
相关问题