docker ,nginx容器+php容器,怎么能获取到访问者的真实ip
2018-09-24 18:40:15
大孟
  • 访问次数: 4
  • 注册日期: 2018-09-24
  • 最后登录: 2018-09-25

docker ,nginx容器+php容器,怎么能获取到访问者的真实ip。

环境搭好之后,获取到的访问地址,是docker网关的地址,怎么才能获取到真实的用户地址

沙发
2018-09-24 18:44:24
大孟
  • 访问次数: 4
  • 注册日期: 2018-09-24
  • 最后登录: 2018-09-25

docker-compose内容,用的是https://github.com/yeszao/dnmp


version: "3"
services:
  nginx:
    build: ./nginx/build/
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /data/wwwroot/:/data/wwwroot/:rw
      - ./nginx/conf/conf.d:/etc/nginx/conf.d/:ro
      - ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/log/:/var/log/dnmp/:rw
    restart: always
    networks:
      - net-php

  php72:
    build: ./php72/build/
    expose:
      - "9000"
    volumes:
      - /data/wwwroot/:/data/wwwroot/:rw
      - ./php72/conf/php.ini:/usr/local/etc/php/php.ini:ro
      - ./php72/conf/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf:rw
      - ./php72/log/:/var/log/dnmp/:rw
    restart: always
    networks:
      - net-php
      - net-mysql
      - net-redis

  mysql8:
    image: mysql:8.0
    ports:
      - "3306:3306"
    volumes:
      - ./mysql8/conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf:ro
      - ./mysql8/data/:/var/lib/mysql/:rw
    restart: always
    networks:
      - net-mysql
    environment:
      MYSQL_ROOT_PASSWORD: "10079894"

#  redis:
#    image: redis:4.0
#    restart: always
#    networks:
#      - net-redis
#    ports:
#      - "6379:6379"
#
#  phpmyadmin:
#    image: phpmyadmin/phpmyadmin:latest
#    ports:
#      - "8080:80"
#    networks:
#      - net-mysql
#    environment:
#      - PMA_HOST=mysql
#      - PMA_PORT=3306
#
#  phpredisadmin:
#    image: erikdubbelboer/phpredisadmin:latest
#    ports:
#      - "8081:80"
#    networks:
#      - net-redis
#    environment:
#      - REDIS_1_HOST=redis
#      - REDIS_1_PORT=6379

networks:
  net-php:
  net-mysql:
  net-redis:

板凳
2018-09-26 10:00:08
李明
  • 访问次数: 379
  • 注册日期: 2018-07-09
  • 最后登录: 2020-03-30

这跟docker没关系,php代码就可以获得

1/1