简体   繁体   中英

How to get client ip from request using symfony in docker

I try to get the ip using:

$request->getClientIp()

Which returns:

172.30.0.1 instead of something like 210.110.98.180

Using this something like this in docker-compose

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

Fixed it by adding it to a docker network.

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

networks:
  bridge2:
    external: true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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