proxy_pass API via - locaion /customer1 - directive does not work .

43 views
Skip to first unread message

DvrX

unread,
Oct 14, 2017, 5:13:05 PM10/14/17
to openresty-en
Hi All

I am trying to use proxy_pass API via location direction as shown below but it does not work in browser (error log says no such file ). But if proxy_pass API is called via  root location /   it work.  Even curl -i  seems ok (shown below ) . Please help it out where I am goin wrong . 


config code for location
#################
  location /customer1 {
           
    proxy_set_header HOST $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_pass http://10.10.10.7:8080/;
 
   }



Output  curl -i

[root~]# curl -i 10.10.10.3/customer1
HTTP/1.1 200 OK
Server: openresty/1.11.2.5
Date: Sat, 14 Oct 2017 21:01:36 GMT
Content-Type: text/html
Content-Length: 519
Connection: keep-alive
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Last-Modified: Thu, 08 Jun 2017 19:42:36 GMT
ETag: "207-551780e00a56c"
Accept-Ranges: bytes
Vary: Accept-Encoding
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>nGenius Redirect</title>
        <script type="text/javascript">
                function launchSplash()
                {
                        var newPath = "/common/NSLogin.jsp?redirect=/console";
                        var host = document.location.host;
                        var protocol = document.location.protocol + "//";
                        var splashURL = protocol + host + newPath;
                        return splashURL;
                }
                var website = launchSplash();
                window.location = website;
        </script>
</head>

<body>
</body>
</html>


##### error.log #############

2017/10/14 17:11:59 [error] 7821#7821: *33531 open() "/usr/local/openresty/nginx/html/common/NSLogin.jsp" failed (2: No such file or directory), client: 10.10.10.1, server: localhost, request: "GET /common/NSLogin.jsp?redirect=/console HTTP/1.1", host: "10.10.10.3", referrer: "http://10.10.10.3/customer1"
2017/10/14 17:11:59 [error] 7821#7821: *33531 open() "/usr/local/openresty/nginx/html/common/NSLogin.jsp" failed (2: No such file or directory), client: 10.10.10.1, server: localhost, request: "GET /common/NSLogin.jsp?redirect=/console HTTP/1.1", host: "10.10.10.3", referrer: "http://10.10.10.3/customer1"
2017/10/14 17:11:59 [error] 7821#7821: *33531 open() "/usr/local/openresty/nginx/html/common/NSLogin.jsp" failed (2: No such file or directory), client: 10.10.10.1, server: localhost, request: "GET /common/NSLogin.jsp?redirect=/console HTTP/1.1", host: "10.10.10.3", referrer: "http://10.10.10.3/customer1"






Jesse Skinner

unread,
Oct 14, 2017, 11:08:55 PM10/14/17
to openre...@googlegroups.com
Hello,

I believe your /customer1 endpoint is working fine, but in the page response, there's some JavaScript that attempts to load /common/NSLogin.jsp?redirect=/console on your server, and it's this URL that is causing the "No such file" errors.

You mention that it works on root, and this would make sense, as then the /common/NSLogin.jsp URL would be proxied through.

So, your solution will require either updating this JavaScript to incorporate the /customer1 into the URL, or else add a location directive to proxy /common/NSLogin.jsp or something to that effect.

I hope that helps a bit.

Best,
Jesse


--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages