nginx中的angular2应用程序:当我绑定主机8080时,stable-alpine docker图像尝试获取sockjs URL - >容器80,但不是80-> 80

时间:2016-08-02 18:42:42

标签: nginx docker angular

正如问题所述,我在nginx docker镜像中有一个与webpack捆绑在一起的角度2应用程序。我运行webpack并缩小/分块我的模块,并将我的所有资源添加到/ usr / share / nginx / html目录中。我不会更改nginx.conf文件或其他任何内容。当我执行如下命令时:

docker run -p 80:80 -d app_nginx

然后导航到localhost,我得到了一个合理的日志:

10.0.2.2 - - [02/Aug/2016:17:45:37 +0000] "GET / HTTP/1.1" 200 1288 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:37 +0000] "GET /css/app.8335816ecce8c3fbf5c2.css HTTP/1.1" 200 3620 "http://localhost/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:37 +0000] "GET /js/polyfills.8335816ecce8c3fbf5c2.js HTTP/1.1" 200 194181 "http://localhost/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:37 +0000] "GET /js/app.8335816ecce8c3fbf5c2.js HTTP/1.1" 200 191859 "http://localhost/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:37 +0000] "GET /css/app.8335816ecce8c3fbf5c2.css.map HTTP/1.1" 200 10799 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:37 +0000] "GET /js/vendor.8335816ecce8c3fbf5c2.js HTTP/1.1" 200 2840585 "http://localhost/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:37 +0000] "GET /js/polyfills.8335816ecce8c3fbf5c2.js.map HTTP/1.1" 200 909488 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:38 +0000] "GET /js/app.8335816ecce8c3fbf5c2.js.map HTTP/1.1" 200 783837 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:38 +0000] "GET /js/vendor.8335816ecce8c3fbf5c2.js.map HTTP/1.1" 200 10331786 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:17:45:38 +0000] "GET /favicon.ico HTTP/1.1" 200 766 "http://localhost/todos" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/08/02 17:51:02 [error] 5#5: *12 open()   "/usr/share/nginx/html/currentsetting.htm" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /currentsetting.htm HTTP/1.1", host: "10.25.114.169"
10.0.2.2 - - [02/Aug/2016:17:51:02 +0000] "GET /currentsetting.htm HTTP/1.1" 404 169 "-" "-" "-"

我不完全确定倒数第二个错误行是什么,但我在所有CSS,JS等上都有200个。

当我执行如下命令时:

docker run -p 8080:80 -d app_nginx

我得到更多更奇怪的日志输出:

10.0.2.2 - - [02/Aug/2016:18:18:57 +0000] "GET /sockjs-node/info?t=1470161937983 HTTP/1.1" 404 571 "http://localhost:8080/todos" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/08/02 18:18:57 [error] 5#5: *1 open() "/usr/share/nginx/html/sockjs-node/info" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /sockjs-node/info?t=1470161937983 HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/todos"
2016/08/02 18:19:03 [error] 5#5: *1 open() "/usr/share/nginx/html/sockjs-node/info" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /sockjs-node/info?t=1470161943983 HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/todos"
10.0.2.2 - - [02/Aug/2016:18:19:03 +0000] "GET /sockjs-node/info?t=1470161943983 HTTP/1.1" 404 571 "http://localhost:8080/todos" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/08/02 18:19:09 [error] 5#5: *1 open() "/usr/share/nginx/html/sockjs-node/info" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /sockjs-node/info?t=1470161949988 HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/todos"
10.0.2.2 - - [02/Aug/2016:18:19:09 +0000] "GET /sockjs-node/info?t=1470161949988 HTTP/1.1" 404 571 "http://localhost:8080/todos" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:18:19:15 +0000] "GET /sockjs-node/info?t=1470161955991 HTTP/1.1" 404 571 "http://localhost:8080/todos" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/08/02 18:19:15 [error] 5#5: *1 open() "/usr/share/nginx/html/sockjs-node/info" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /sockjs-node/info?t=1470161955991 HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/todos"
10.0.2.2 - - [02/Aug/2016:18:19:19 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:18:19:19 +0000] "GET    /js/vendor.8335816ecce8c3fbf5c2.js HTTP/1.1" 304 0 "http://localhost:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:18:19:19 +0000] "GET /js/polyfills.8335816ecce8c3fbf5c2.js HTTP/1.1" 304 0 "http://localhost:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:18:19:19 +0000] "GET /js/app.8335816ecce8c3fbf5c2.js HTTP/1.1" 304 0 "http://localhost:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
10.0.2.2 - - [02/Aug/2016:18:19:19 +0000] "GET /css/app.8335816ecce8c3fbf5c2.css HTTP/1.1" 304 0 "http://localhost:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/08/02 18:19:21 [error] 5#5: *4 open() "/usr/share/nginx/html/sockjs-node/info" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /sockjs-node/info?t=1470161961988 HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/todos"
10.0.2.2 - - [02/Aug/2016:18:19:21 +0000] "GET /sockjs-node/info?t=1470161961988 HTTP/1.1" 404 571 "http://localhost:8080/todos" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/08/02 18:19:26 [error] 5#5: *4 open() "/usr/share/nginx/html/sockjs-node/info" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /sockjs-node/info?t=1470161966988 HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/todos"
10.0.2.2 - - [02/Aug/2016:18:19:26 +0000] "GET /sockjs-node/info?t=1470161966988 HTTP/1.1" 404 571 "http://localhost:8080/todos" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" "-"
2016/08/02 18:19:32 [error] 5#5: *4 open() "/usr/share/nginx/html/sockjs-node/info" failed (2: No such file or directory), client: 10.0.2.2, server: localhost, request: "GET /sockjs-node/info?t=1470161972989 HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/todos"

注意我可以使用这些容器之一查看webapp并与之交互。我没有做任何我知道的websocket调用。这是捆绑的,编译的typescript / html / css。我的问题是:

  1. 我认为如果我将主机端口8080绑定到nginx侦听的容器端口80,它就会工作。相反,似乎它试图从localhost:8080获取。我希望它只是尝试从localhost获取,就像在第一个日志中一样。

0 个答案:

没有答案