Hi Team ISPConfig I am trying to password protect a folder on NGINX and getting Error 502 - Bad gateway I am using Debian 12, PHP 8.2 on ISPConfig 3.3.0p3 and the Document Root is /var/www/clients/client0/web28 This is my NGINX Directive entered via ISPConfig nginx Directives UI: - Code: #RESTRICT USER ACCESS ###WARNING THIS MUST ALWAYS BE THE FIRST BLOCK OR IT WILL NOT WORK### location ^~ /media_asset_main/ { location ~ \.php$ { try_files $uri =404; include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/lib/php8.2-fpm/web28.sock; ##web?? needs to match Linux User for our website fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; } auth_basic "Hello, please login"; auth_basic_user_file /var/www/foo.foo.com/private/.htpasswd; } #RESTRICT USER ACCESS ###WARNING THIS MUST ALWAYS BE THE FIRST BLOCK OR IT WILL NOT WORK### When I try and access "https://foo.foo.com/media_asset_main/mediaupdate.php I get: - 1/ Auth popup which works all OK 2/ Error 502 - Bad gateway This is the error that gets logged: - Code: 2026/02/01 13:36:15 [crit] 2098141#2098141: *8 connect() to unix:/var/lib/php8.2-fpm/web28.sock failed (2: No such file or directory) while connecting to upstream, client: 123.123.123.123, server: foo.foo.com, request: "GET /media_asset_main/mediaupdate.php HTTP/2.0", upstream: "fastcgi://unix:/var/lib/php8.2-fpm/web28.sock:", host: "foo.foo.com" If I remove the above block of directive everything works as expected! I just cannot see what I am doing wrong??? I need to be able to process .php files which are password protected. Any pointers / help would be very welcome. Many thanks in advance for any kind help Regards HTA
Try this to test your nginx configs (sure there are a lot of others out there): https://www.getpagespeed.com/check-nginx-config So far it only says "try_files $uri =404;" is the culprit.
Hi ahrasis - Thank You for your time. Sadly that did not resolve the issue! Thanks also for the nginx config checkup link - very useful Kind regards HTA
Hi all, I managed to solve the problem! If anyone has this issue, please see the solution below: - Code: ## RESTRICT USER ACCESS - START location ^~ /media_asset_main/ { location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/run/php/web23.sock; ##web?? needs to match Linux User for our website fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; } auth_basic "Hello, please login"; auth_basic_user_file /var/www/foo.foo.com/private/.htpasswd; } ## RESTRICT USER ACCESS - END Hope this helps someone? Kind regards HTA
Will it work if you remove this part in your added directive as I think by default, ISPConfig already set it in each website's vhost. Code: location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/run/php/web23.sock; ##web?? needs to match Linux User for our website fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; }
And he probably could just have used the folder protection feature in ISPConfig instead of inserting custom directives.
Hi ahrasis, The short answer is no it will not work by removing the code you mention! If I did that, the PHP file would just get downloaded. Regards HTA
Hi Till, I need four different people (with unique passwords) to be able to run various PHP scripts in that folder! I believe that the folder protection feature in ISPConfig is limited to one user? HTA