Score:1

Why is php-fpm getting the wrong client ip address?

jp flag

Good day!

I have two docker containers php-fpm and nginx I need to get the real ip address of the client, but instead of 127.0.0.1 (localhost) I get 172.0.0.1 what could be the problem?

Below I have indicated the configuration that I am using, as well as a picture so that you could understand me better.

how i see interaction. Smile-client

version: "3.9"

services:
    nginx:
        build: ./nginx
        ports:
          - 80:80
        volumes:
            - ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
            - ./nginx/conf/hosts:/etc/hosts

            - ./app:/var/www/app
        networks:
            - app_network

    php-fpm:
        build: ./phpfpm
        depends_on:
            - nginx
        volumes:
            - ./phpfpm/conf/www.conf:/usr/local/etc/php-fpm.d/www.conf
            - ./phpfpm/conf/hosts:/etc/hosts

            - ./app:/var/www/app
        networks:
            - app_network
    
networks:
    app_network:
        ipam:
            driver: default
            config:
                - subnet: "172.0.0.0/24"
                - subnet: "2001:3984:3989::/64"

as you can see I have merged host port 80 with container port 80 so I expect the correct ip to be passed. What am I doing wrong? I would be grateful for any answer, thanks in advance !!

in flag
Please post your nginx config.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.