C
C
cowan2020-03-18 19:16:21
Nginx
cowan, 2020-03-18 19:16:21

How to set up php processing for multiple locations in nginx?

Hello!
Set a password to access the Joomla admin panel in nginx:

location ^~ /administrator/ {
  auth_basic "Restricted";
  auth_basic_user_file /etc/nginx/.htpasswd;

The password request occurs correctly, i.e. when accessing ../administrator and ../administrator/index.php.
But the question is that for location ^~ /administrator/ you have to write the whole location ~* \.php$ again
location ~* \.php$ {
# размеры буффера
    fastcgi_buffer_size 128k;
  fastcgi_buffers 256 4k;
  fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
  try_files $uri = 404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

# сокет php-fpm
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME
  $document_root$fastcgi_script_name;
  include fastcgi_params;
  fastcgi_read_timeout 300;


Is this true or should it be optimized?

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