V
V
voker20052019-08-31 20:36:39
PHP
voker2005, 2019-08-31 20:36:39

Why does Nginx give a 500 error when enabling the auth_request module?

Good afternoon colleagues.
Installed Nginx1.16.1 , ran sudo nginx -V , I see that --with-http_auth_request_module is included in the build, great.
Installed php7.3-fpm . Did the nano setup /etc/php/7.3/fpm/pool.d/ www.conf :

[www]
 
user = nginx
group = nginx
 
listen = /run/php/php7.3-fpm.sock
 
listen.owner = nginx
listen.group = nginx
 
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

Created a php file with <?php phpinfo(); ?>, I go to the browser, I check, everything is OK.
5d6aac8447ea4839785659.jpeg
I go to the virtual host config, enable the auth_request module in the following way:
server {
    listen       80;
    server_name  my.domain.com;
        root   /var/www/devops/data/my.domain.com/www;
        index  index.php index.html index.htm;

    location / {
        auth_request /auth;

        location ~ \.php$ {
                include       /etc/nginx/fastcgi_params;
                fastcgi_index index.php;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        }

    }

        location = /auth {
                proxy_pass       http://my.domain.com/index.php;
                proxy_pass_request_body off;
                proxy_set_header Content-Length "";
                proxy_set_header X-Original-URI $request_uri;
        }
}

I go to the browser, I open it, it gives an error 500 Internal Server Error
As soon as I comment / disable auth_request / auth; the php test page is working correctly.
Logs
2019/08/31 20:25:04 [error] 9952#9952: *4 auth request unexpected status: 500 while sending to client, client: 127.0.0.1, server: my.domain.com, request: "GET /index.php HTTP/1.0", host: "my.domain.com"

2019/08/31 20:25:04 [error] 9952#9952: *2 auth request unexpected status: 500 while sending to client, client: 10.14.14.30, server: my.domain.com, request: "GET / HTTP/1.1", host: "my.domain.com"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question