2015-08-31 43 views
1

我在docker中创建了一个apache服务器,但是ip在访问日志中获得的仅仅是我的docker ip,而不是来自远程客户端ip。是否有可能通过在docker中运行apache获得远程ip

是否有可能获得远程IP?

我试图使用mod_remoteip,它不工作。

+0

您可以发布您Dockerfile或码头运行命令来启动Apache?我已经在我的apache映像上进行了测试,并且可以在访问日志中看到外部IP地址。 – booyaa

+0

docker run -it -p 90:80 image_id bash – Chen

回答

0

Dockerfile

FROM ubuntu:latest 

ENV DEBIAN_FRONTEND noninteractive 

# make sure the package repository is up to date and update ubuntu 
RUN locale-gen de_DE.UTF-8 
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d 

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates 
RUN apt-get update && apt-get install -y curl lsb-release supervisor openssh-server libapache2-mod-passenger git apache2 vim 


# supervisor installation && 
# create directory for child images to store configuration in 
RUN apt-get -y install supervisor && \ 
mkdir -p /var/run/sshd && \ 
mkdir -p /var/log/supervisor && \ 
mkdir -p /etc/supervisor/conf.d 


# default command 
CMD ["/usr/bin/supervisord"] 
+0

运行docker后,我刚刚得到以下apache日志:172.17.42.1 - - [24/Sep/2015:15:42:24 +0000]“GET/HTTP/1.1“200 11764” - “”curl/7.35.0“ 172.17.42.1 - - [24/Sep/2015:15:42:26 +0000]”GET/HTTP/1.1“200 11764” - “”curl/7.35.0“ 172.17.42.1 - - [24/Sep/2015:15:42:29 +0000]”GET/HTTP/1.1“200 11764” - “”curl/7.35.0“ 172.17.42.1 - [24/Sep/2015:15:42:31 +0000]“GET/HTTP/1.1”200 11764“ - ”“curl/7.35.0” – Chen

相关问题