0

I am trying to set up nginx proxy in front of nodejs proxy app to aws elasticsearch app in a docker.

the first container is listen to port 9100, and the other one listen to port 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

Location root / works properly, when I go to http://my.domain.com/_plugin/kibana nginx proxy to http://127.0.0.1:9200/_plugin/kibana.

Location /kibana-test doesnt work, I get 404 if I go to http://my.domain.com/kibana-test/_plugin/kibana.

Any idea why ?

Thanks

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;
        }                           

    }
} 

error log debug:

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
4
  • What URI does service 9100 expect? Currently you are sending it http://127.0.0.1:9100/kibana-test/_plugin/kibana Commented Jan 31, 2017 at 11:19
  • what do you mean with expect ? same app just different container, it will also not work if I will change the port to 9200 like the root location, basically its container with nodejs that proxy to aws es. Commented Jan 31, 2017 at 11:28
  • @RichardSmith please see this repo https://github.com/santthosh/aws-es-kibana Commented Jan 31, 2017 at 11:29
  • @RichardSmith do you like to see the error debug log? Commented Jan 31, 2017 at 11:30

1 Answer 1

1

I think you need to put the location= /kibana-test before the location= /, Because otherwise nginx will get its first match and will not match further

Sign up to request clarification or add additional context in comments.

2 Comments

If the root location after location /kibana-test/?(.*) { I still getting 404, so strange its works with root location and not other location
you right , I put location = / at the beginning, so it will skip the root location, but still I see 404

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.