Jeroen de Beer
Jeroen de Beer

Reputation: 340

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"

Upvotes: 1

Views: 851

Answers (1)

Jeroen de Beer
Jeroen de Beer

Reputation: 340

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

Upvotes: 1

Related Questions