Docker中的烧瓶:在日志中找到完全不同类型的请求源IP

时间:2019-01-08 09:12:31

标签: docker network-programming iptables

我在docker中部署了flask应用,还启用了iptables。 关于日志中请求的源IP,有2个问题。

  1. 当我访问网站(通过计算机或手机)时,显示所有请求均来自日志中的“ 172.17.0.1”(这是docker网关IP地址)。

    我找到了这个答案:why-i-get-the-gateway-ip-as-source-address-in-docker-bridge-networking。 这个问题的根本原因应该与他相同,但是他没有描述如何调试导致此问题的条目。

  2. 我尝试了几种方法来访问该网站:从计算机或手机的浏览器,wget,使用python脚本的http.get。所有这些都表明请求来自127.17.0.1。但是,我还发现很多请求不是来自127.17.0.1,这些请求不是我发送的,所以我很困惑。这些请求来自哪里,为什么不是127.17.0.1中的请求,以及使用了哪些方式?

从日志文件中附加了一些日志:

这些日志是我的要求:

[pid: 6|app: 0|req: 116/116] 172.17.0.1 () {38 vars in 698 bytes} [Sun Jan  6 15:58:01 2019] GET / => generated 593 bytes in 4 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 0)
[pid: 6|app: 0|req: 117/117] 172.17.0.1 () {38 vars in 699 bytes} [Sun Jan  6 15:58:01 2019] GET /styles.dacf3243c84614b36bbd.css => generated 131481 bytes in 19 msecs via sendfile() (HTTP/1.1 200) 11 headers in 470 bytes (0 switches on core 2)
[pid: 6|app: 0|req: 119/118] 172.17.0.1 () {38 vars in 684 bytes} [Sun Jan  6 15:58:01 2019] GET /runtime.ec2944dd8b20ec099bf3.js => generated 1440 bytes in 2 msecs via sendfile() (HTTP/1.1 200) 11 headers in 465 bytes (0 switches on core 3)
[pid: 6|app: 0|req: 119/119] 172.17.0.1 () {38 vars in 688 bytes} [Sun Jan  6 15:58:01 2019] GET /polyfills.1ef83d22ada557f4a131.js => generated 38390 bytes in 1 msecs via sendfile() (HTTP/1.1 200) 11 headers in 466 bytes (0 switches on core 4)
[pid: 6|app: 0|req: 120/120] 172.17.0.1 () {38 vars in 678 bytes} [Sun Jan  6 15:58:01 2019] GET /main.2403d525ee7c745f5c5e.js => generated 499979 bytes in 2 msecs via sendfile() (HTTP/1.1 200) 11 headers in 469 bytes (1 switches on core 1)
[pid: 6|app: 0|req: 121/121] 172.17.0.1 () {38 vars in 702 bytes} [Sun Jan  6 15:58:01 2019] GET /assets/images/city.png => generated 28468 bytes in 1 msecs via sendfile() (HTTP/1.1 200) 11 headers in 453 bytes (0 switches on core 8)
[pid: 6|app: 0|req: 122/122] 172.17.0.1 () {38 vars in 706 bytes} [Sun Jan  6 15:58:01 2019] GET /assets/images/search.png => generated 1463 bytes in 1 msecs via sendfile() (HTTP/1.1 200) 11 headers in 452 bytes (0 switches on core 6)
[pid: 6|app: 0|req: 123/123] 172.17.0.1 () {38 vars in 719 bytes} [Sun Jan  6 15:58:09 2019] GET /search/all?key=%E6%B5%B7&&offset=0 => generated 879 bytes in 237 msecs (HTTP/1.1 200) 5 headers in 237 bytes (1 switches on core 7)

这些来自其他人,这使我感到困惑,为什么源IP不是127.17.0.1?

[pid: 6|app: 0|req: 142/142] 51.15.191.81 () {26 vars in 420 bytes} [Sun Jan  6 22:22:26 2019] GET / => generated 593 bytes in 3 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 7)
[pid: 6|app: 0|req: 143/143] 81.215.201.214 () {24 vars in 363 bytes} [Sun Jan  6 22:34:41 2019] GET / => generated 593 bytes in 2 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 9)
[pid: 6|app: 0|req: 144/144] 111.68.102.15 () {24 vars in 362 bytes} [Sun Jan  6 23:53:59 2019] GET / => generated 593 bytes in 2 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 5)
[pid: 6|app: 0|req: 145/145] 185.80.162.38 () {24 vars in 363 bytes} [Mon Jan  7 03:21:56 2019] GET / => generated 593 bytes in 26 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 0)
[pid: 6|app: 0|req: 146/146] 37.6.49.36 () {24 vars in 360 bytes} [Mon Jan  7 03:27:11 2019] GET / => generated 593 bytes in 3 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 2)
[pid: 6|app: 0|req: 147/147] 103.90.204.204 () {24 vars in 363 bytes} [Mon Jan  7 03:35:11 2019] GET / => generated 593 bytes in 2 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 3)
[pid: 6|app: 0|req: 148/148] 190.186.87.238 () {24 vars in 370 bytes} [Mon Jan  7 03:43:50 2019] GET / => generated 593 bytes in 2 msecs (HTTP/1.1 200) 5 headers in 245 bytes (1 switches on core 4)

0 个答案:

没有答案