2017-01-31 8 views
0

Я пытаюсь настроить прокси-сервер nginx перед прокси-файлом nodejs на приложение 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

Какой URI-сервис 9100 ожидает? В настоящее время вы отправляете его '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