2

I'am running ddev under macos with apple silicon m1. I'am trying to open a phar (Contao-Manager.phar.php) file in the browser but got a 404. webroot is correctly set, because its is possible to open a test.php in same webroot in the browser.

Here Is My nginx-conf:

server {
    listen 80 default_server;
    listen 443 ssl default_server;
    root /var/www/html/web;
    ssl_certificate /etc/ssl/certs/master.crt;
    ssl_certificate_key /etc/ssl/certs/master.key;

    include /etc/nginx/monitoring.conf;

    index index.php index.htm index.html;

    sendfile off;
    error_log /dev/stdout info;
    access_log /var/log/nginx/access.log;

    location / {
        absolute_redirect off;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location @rewrite {
        rewrite ^ /index.php;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass unix:/run/php-fpm.sock;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_intercept_errors off;
        fastcgi_read_timeout 10m;
        fastcgi_param SERVER_NAME $host;
        fastcgi_param HTTPS $fcgi_https;
        
    }

    location ~* /\.(?!well-known\/) {
        deny all;
    }

    location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op])|~)$ {
        deny all;
    }

    include /etc/nginx/common.d/*.conf;
    include /mnt/ddev_config/nginx/*.conf;
}
iiorka
  • 21
  • 2
  • What do you mean saying "open a phar.php"? Do you want to parse it with php engine, to pass it to your php-fpm socket? –  Apr 11 '22 at 15:41
  • I want to open it in the browser :) Sorry for bad english – iiorka Apr 12 '22 at 10:02

1 Answers1

0

Try to change your default location to this (didn't check if works):

location / {
    absolute_redirect off;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    try_files $fastcgi_script_name $uri $uri/ /index.php?$query_string;
}

And check your access.log and error.log if it's not working.

The problem is somewhere between fastcgi_split_path_info and your location order (which location actually handles *.php request first).

It is also possible that your regular expression in fastcgi_split_path_info doesn't match Contao-Manager.phar.php (file has 2 extensions).

  • Did not work. And can't find any information in error.log or access.log, because both are empty – iiorka Apr 13 '22 at 07:58
  • @iiorka I think you should change `error_log /dev/stdout info;` to something like this `error_log /var/log/nginx/error.log`, re-load nginx and then try one more time –  Apr 13 '22 at 08:29