2017-01-31 79 views
0

工作我想在代理的NodeJS應用程序的前面設置的nginx代理AWS在泊塢窗elasticsearch應用。nginx的位置指令不與代理的NodeJS應用

第一容器偵聽端口9100,而另一個偵聽端口9200

tcp  0  0 127.0.0.1:9100   0.0.0.0:*    LISTEN  26499/docker-proxy 
tcp  0  0 127.0.0.1:9200   0.0.0.0:*    LISTEN  4899/docker-proxy 

位置根/正常工作,當我去http://my.domain.com/_plugin/kibana nginx的代理http://127.0.0.1:9200/_plugin/kibana

位置/kibana-test不工作,我得到404如果我去http://my.domain.com/kibana-test/_plugin/kibana

任何想法爲什麼?

感謝

user www-data; 
worker_processes auto; 
pid /run/nginx.pid; 

events { 
     worker_connections 768; 
     # multi_accept on; 
} 

http { 

    include  /etc/nginx/mime.types; 
    default_type application/octet-stream; 
    log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
         '$status $body_bytes_sent "$http_referer" ' 
         '"$http_user_agent" "$http_x_forwarded_for"' 
         '$uri $request_uri' 


    access_log /var/log/nginx/access.log main; 
    sendfile  on; 
    keepalive_timeout 65; 

    server { 

     listen 80 default_server; 
     listen [::]:80 default_server ipv6only=on; 

     location =/{ 
     proxy_set_header X-Real-IP 10.10.10.1; 
     proxy_http_version 1.1; 
     proxy_set_header Connect "Keep-Alive"; 
     proxy_set_header Proxy-Connection "Keep-Alive"; 
     proxy_set_header Authorization ""; 
     proxy_pass http://127.0.0.1:9200; 
     } 

     location /kibana-test/?(.*) { 
     proxy_set_header X-Real-IP 10.10.10.1; 
     proxy_http_version 1.1; 
     proxy_set_header Connect "Keep-Alive"; 
     proxy_set_header Proxy-Connection "Keep-Alive"; 
     proxy_set_header Authorization ""; 
     proxy_pass http://127.0.0.1:9100; 
     }       

    } 
} 

錯誤日誌調試:

2017/01/31 11:44:49 [debug] 15308#15308: *1 post event 00005597376E5B30 
2017/01/31 11:44:49 [debug] 15308#15308: *1 post event 00005597376F7B40 
2017/01/31 11:44:49 [debug] 15308#15308: *1 delete posted event 00005597376E5B30 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http keepalive handler 
2017/01/31 11:44:49 [debug] 15308#15308: *1 malloc: 00005597376D53B0:1024 
2017/01/31 11:44:49 [debug] 15308#15308: *1 recv: fd:8 368 of 1024 
2017/01/31 11:44:49 [debug] 15308#15308: *1 reusable connection: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 posix_memalign: 00005597376C7F70:4096 @16 
2017/01/31 11:44:49 [debug] 15308#15308: *1 event timer del: 8: 1485863133868 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http process request line 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http request line: "GET /kibana-test/_plugin/kibana HTTP/1.1" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http uri: "/kibana-test/_plugin/kibana" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http args: "" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http exten: "" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http process request header line 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header: "Host: my.domain.com" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header: "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header: "Accept-Language: en-US,en;q=0.5" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header: "Accept-Encoding: gzip, deflate" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header: "Connection: keep-alive" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header: "Upgrade-Insecure-Requests: 1" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http header done 
2017/01/31 11:44:49 [debug] 15308#15308: *1 generic phase: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 rewrite phase: 1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 test location: "/" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 test location: "kibana-test/?(.*)" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 using configuration "/" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http cl:-1 max:1048576 
2017/01/31 11:44:49 [debug] 15308#15308: *1 rewrite phase: 3 
2017/01/31 11:44:49 [debug] 15308#15308: *1 post rewrite phase: 4 
2017/01/31 11:44:49 [debug] 15308#15308: *1 generic phase: 5 
2017/01/31 11:44:49 [debug] 15308#15308: *1 generic phase: 6 
2017/01/31 11:44:49 [debug] 15308#15308: *1 generic phase: 7 
2017/01/31 11:44:49 [debug] 15308#15308: *1 access phase: 8 
2017/01/31 11:44:49 [debug] 15308#15308: *1 access phase: 9 
2017/01/31 11:44:49 [debug] 15308#15308: *1 access phase: 10 
2017/01/31 11:44:49 [debug] 15308#15308: *1 post access phase: 11 
2017/01/31 11:44:49 [debug] 15308#15308: *1 posix_memalign: 00005597376BABD0:4096 @16 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http init upstream, client timer: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http script copy: "X-Real-IP: 10.10.10.1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http script copy: "Connect: Keep-Alive 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http script copy: "Proxy-Connection: Keep-Alive 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http script copy: "Host: " 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http script var: "127.0.0.1:9200" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http script copy: " 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http script copy: "Connection: close 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "Accept-Language: en-US,en;q=0.5" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "Accept-Encoding: gzip, deflate" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "Upgrade-Insecure-Requests: 1" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: 
"GET /kibana-test/_plugin/kibana HTTP/1.1 
X-Real-IP: 10.10.10.1 
Connect: Keep-Alive 
Proxy-Connection: Keep-Alive 
Host: 127.0.0.1:9200 
Connection: close 
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-US,en;q=0.5 
Accept-Encoding: gzip, deflate 
Upgrade-Insecure-Requests: 1 

" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http cleanup add: 00005597376BB4A8 
2017/01/31 11:44:49 [debug] 15308#15308: *1 get rr peer, try: 1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 stream socket 9 
2017/01/31 11:44:49 [debug] 15308#15308: *1 epoll add connection: fd:9 ev:80002005 
2017/01/31 11:44:49 [debug] 15308#15308: *1 connect to 127.0.0.1:9200, fd:9 #4 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream connect: -2 
2017/01/31 11:44:49 [debug] 15308#15308: *1 posix_memalign: 00005597376B6630:128 @16 
2017/01/31 11:44:49 [debug] 15308#15308: *1 event timer add: 9: 60000:1485863149318 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http finalize request: -4, "/kibana-test/_plugin/kibana?" a:1, c:2 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http request count:2 blk:0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 delete posted event 00005597376F7B40 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http run request: "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream check client, write event:1, "/kibana-test/_plugin/kibana" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream recv(): -1 (11: Resource temporarily unavailable) 
2017/01/31 11:44:49 [debug] 15308#15308: *1 post event 00005597376F7BA0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 delete posted event 00005597376F7BA0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream request: "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream send request handler 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream send request 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream send request body 
2017/01/31 11:44:49 [debug] 15308#15308: *1 chain writer buf fl:1 s:415 
2017/01/31 11:44:49 [debug] 15308#15308: *1 chain writer in: 00005597376BB4E0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 writev: 415 of 415 
2017/01/31 11:44:49 [debug] 15308#15308: *1 chain writer out: 0000000000000000 
2017/01/31 11:44:49 [debug] 15308#15308: *1 event timer del: 9: 1485863149318 
2017/01/31 11:44:49 [debug] 15308#15308: *1 event timer add: 9: 60000:1485863149318 
2017/01/31 11:44:49 [debug] 15308#15308: *1 post event 00005597376E5B90 
2017/01/31 11:44:49 [debug] 15308#15308: *1 post event 00005597376F7BA0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 delete posted event 00005597376E5B90 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream request: "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream process header 
2017/01/31 11:44:49 [debug] 15308#15308: *1 malloc: 00005597376BBBE0:4096 
2017/01/31 11:44:49 [debug] 15308#15308: *1 recv: fd:9 559 of 4096 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy status 404 "404 Not Found" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "X-Powered-By: Express" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "access-control-allow-origin: *" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "content-type: application/json; charset=UTF-8" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "content-length: 331" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "connection: Close" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "Vary: Accept-Encoding" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header: "Date: Tue, 31 Jan 2017 11:44:49 GMT" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy header done 
2017/01/31 11:44:49 [debug] 15308#15308: *1 xslt filter header 
2017/01/31 11:44:49 [debug] 15308#15308: *1 HTTP/1.1 404 Not Found 
Server: nginx/1.10.0 (Ubuntu) 
Date: Tue, 31 Jan 2017 11:44:49 GMT 
Content-Type: application/json; charset=UTF-8 
Content-Length: 331 
Connection: keep-alive 
X-Powered-By: Express 
access-control-allow-origin: * 
Vary: Accept-Encoding 

2017/01/31 11:44:49 [debug] 15308#15308: *1 write new buf t:1 f:0 00005597376BB7F0, pos 00005597376BB7F0, size: 264 file: 0, size: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http write filter: l:0 f:0 s:264 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http cacheable: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http proxy filter init s:404 h:0 c:0 l:331 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream process upstream 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe read upstream: 1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe preread: 331 
2017/01/31 11:44:49 [debug] 15308#15308: *1 readv: 1, last:3537 
2017/01/31 11:44:49 [debug] 15308#15308: *1 readv() not ready (11: Resource temporarily unavailable) 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe recv chain: -2 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe buf free s:0 t:1 f:0 00005597376BBBE0, pos 00005597376BBCC4, size: 331 file: 0, size: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe length: 331 
2017/01/31 11:44:49 [debug] 15308#15308: *1 input buf #0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe write downstream: 1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe write downstream flush in 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http output filter "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http copy filter: "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 image filter 
2017/01/31 11:44:49 [debug] 15308#15308: *1 xslt filter body 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http postpone filter "/kibana-test/_plugin/kibana?" 00005597376BBA30 
2017/01/31 11:44:49 [debug] 15308#15308: *1 write old buf t:1 f:0 00005597376BB7F0, pos 00005597376BB7F0, size: 264 file: 0, size: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 write new buf t:1 f:0 00005597376BBBE0, pos 00005597376BBCC4, size: 331 file: 0, size: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http write filter: l:0 f:0 s:595 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http copy filter: 0 "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 pipe write downstream done 
2017/01/31 11:44:49 [debug] 15308#15308: *1 event timer: 9, old: 1485863149318, new: 1485863149382 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream exit: 0000000000000000 
2017/01/31 11:44:49 [debug] 15308#15308: *1 finalize http upstream request: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 finalize http proxy request 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free rr peer 1 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 close http upstream connection: 9 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free: 00005597376B6630, unused: 48 
2017/01/31 11:44:49 [debug] 15308#15308: *1 event timer del: 9: 1485863149318 
2017/01/31 11:44:49 [debug] 15308#15308: *1 delete posted event 00005597376F7BA0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 reusable connection: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http upstream temp fd: -1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http output filter "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http copy filter: "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 image filter 
2017/01/31 11:44:49 [debug] 15308#15308: *1 xslt filter body 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http postpone filter "/kibana-test/_plugin/kibana?" 00007FFDFE6952B0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 write old buf t:1 f:0 00005597376BB7F0, pos 00005597376BB7F0, size: 264 file: 0, size: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 write old buf t:1 f:0 00005597376BBBE0, pos 00005597376BBCC4, size: 331 file: 0, size: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 write new buf t:0 f:0 0000000000000000, pos 0000000000000000, size: 0 file: 0, size: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http write filter: l:1 f:0 s:595 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http write filter limit 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 writev: 595 of 595 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http write filter 0000000000000000 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http copy filter: 0 "/kibana-test/_plugin/kibana?" 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http finalize request: 0, "/kibana-test/_plugin/kibana?" a:1, c:1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 set http keepalive handler 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http close request 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http log handler 
2017/01/31 11:44:49 [debug] 15308#15308: *1 posix_memalign: 00005597376BCBF0:4096 @16 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free: 00005597376BBBE0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free: 00005597376C7F70, unused: 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free: 00005597376BABD0, unused: 104 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free: 00005597376BCBF0, unused: 3856 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free: 00005597376D53B0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 hc free: 0000000000000000 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 hc busy: 0000000000000000 0 
2017/01/31 11:44:49 [debug] 15308#15308: *1 reusable connection: 1 
2017/01/31 11:44:49 [debug] 15308#15308: *1 event timer add: 8: 65000:1485863154382 
2017/01/31 11:44:49 [debug] 15308#15308: *1 post event 00005597376E5B30 
2017/01/31 11:44:49 [debug] 15308#15308: *1 delete posted event 00005597376E5B30 
2017/01/31 11:44:49 [debug] 15308#15308: *1 http keepalive handler 
2017/01/31 11:44:49 [debug] 15308#15308: *1 malloc: 00005597376D53B0:1024 
2017/01/31 11:44:49 [debug] 15308#15308: *1 recv: fd:8 -1 of 1024 
2017/01/31 11:44:49 [debug] 15308#15308: *1 recv() not ready (11: Resource temporarily unavailable) 
2017/01/31 11:44:49 [debug] 15308#15308: *1 free: 00005597376D53B0 
+0

服務9100期望的URI是什麼?目前你正在發送'http://127.0.0.1:9100/kibana-test/_plugin/kibana' –

+0

你的意思是什麼?相同的應用程序只是不同的容器,如果我將端口更改爲'9200'就像根目錄位置,基本上它的容器有nodejs代理aws es。 – Berlin

+0

@RichardSmith請看這個回購'https:// github.com/santthosh/aws-es-kibana' – Berlin

回答

1

我認爲你需要的位置之前把位置=/kibana測試= /,因爲否則的nginx會得到它的第一場比賽並且不會進一步匹配

+0

如果'location /kibana-test/?((*))'後面的根位置{'我仍然得到'404',那麼它的作品有根位置而不是其他位置 – Berlin

+0

你是對的,我把location = /開頭,所以它會跳過根位置,但我仍然看到404 – Berlin