Yasmin Reda
Yasmin Reda

Reputation: 385

NGINX proxy_pass to another port

I am trying to do an auth_request in nginx by proxy pass but I keep getting:

1 auth request unexpected status: 301

here is my configuration:

server {
    listen      8080;
    server_name  localhost;

    location /my_location/ {
        auth_request /access/auth;
        try_files $uri =404;
    }

    location /access/auth/{
        proxy_pass   http://localhost:5029/server_alias/web_service_name;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }

}

The request should be sent to the apache server which is listening on port 5029. What am i doing wrong ?

Upvotes: 0

Views: 2237

Answers (1)

Yasmin Reda
Yasmin Reda

Reputation: 385

I found the answer for anyone facing the same problem Only a backslash was missing in auth_request path.

location /my_location/ {
    auth_request /access/auth/;
    try_files $uri =404;
}

Upvotes: 2

Related Questions