Welcome! Log In Create A New Profile

Advanced

Nginx - API Gateway is not forwarding the request to Auth Service

April 10, 2017 04:42AM
Hi,

I am trying to implement the NGINX API gateway in nginx 1.10.3 community version. I am facing the issue that NGINX is not forwarding the request to authentication service. nginx configuration is pasted at the end of this thread.

I have written authentication service which is listening for login requests on /login.
My protected application has no login page and responds with 401 status if its tried to be accessed without login in authentication service.

Now according to the nginx auth_request module, if the protected applicaiton throws 401 status then NGINX forwards the request to authentication service for login and after successful login the request is forwarded back to the backend server.
BUT, this is not happening for my configuration. When I try to access my nginx application it is not forwarding the request to auth service. I have verified this by looking at the response headers which has the custom sessionid name of protected application only.

I have checked my installation and it shows that --with-http_auth_request_module is compiled in my installation

NGINX Configuraiton :


http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

# proxy_intercept_errors on;

server {
listen 8180;

location /{
auth_request /login;
proxy_pass http://adi-backend;
}

location /api {
auth_request /login;
proxy_pass http://adi-backend;
}

location = /login {
proxy_pass http://localhost:8080/login;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

upstream adi-backend {
server localhost:8280;
}

upstream authserv {
server localhost:8380;
}

}
Subject Author Posted

Nginx - API Gateway is not forwarding the request to Auth Service

zaidahmd April 10, 2017 04:42AM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

Maxim Dounin April 10, 2017 08:14AM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

zaidahmd April 11, 2017 02:04AM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

zaidahmd April 11, 2017 03:51AM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

Francis Daly April 11, 2017 07:50AM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

zaidahmd April 12, 2017 05:50AM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

Francis Daly April 12, 2017 05:46PM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

zaidahmd April 13, 2017 01:00AM

Re: Nginx - API Gateway is not forwarding the request to Auth Service

Francis Daly April 13, 2017 07:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready