Nginx - API Gateway is not forwarding the request to Auth Service
zaidahmd
nginx-forum at forum.nginx.org
Mon Apr 10 08:42:25 UTC 2017
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;
}
}
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,273515,273515#msg-273515
More information about the nginx
mailing list