0

I would like to execute a custom php file (required for a validation and scan) on our Magento2 installation. The file however should remain and be located in the main /var/www/html/ folder and not in the /var/www/html/pub/ folder.

I have tried the following in my main vhost configuration but still getting a 404

    location /mycustomfile.php {
        try_files $uri $uri/;
        location ~* \.php$ {
        fastcgi_pass fastcgi_backend;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
    }

Also I have seen to "whitelist" the file in /var/www/html/nginx.conf.sample under:

    # PHP entry point for main application
    location ~ 
  
    (index|get|static|report|404|503|health_check|mycustomfile)\.php$ {

Some expert help would be greatly appreciated, thank you!

EDIT:

Okay I figured it out:

    location /mycustomfile.php {
        try_files $uri $uri/;
        root /var/www/html;
        location ~* \.php$ {
        fastcgi_pass fastcgi_backend;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
    }
1

1 Answer 1

0

Okay nevermind, I figured it out now

location /mycustomfile.php {
        try_files $uri $uri/;
        root /var/www/html;
        location ~* \.php$ {
        fastcgi_pass fastcgi_backend;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
    }
3
  • I recommend you provide the solution you applied in order to solve the issue and to mark your question as 'accepted' as solution afterwards.
    – Diana
    Mar 22, 2021 at 9:31
  • I did that directly in the first post
    – David
    Mar 23, 2021 at 5:49
  • oh, ok, it's a bit confusing since you also added this answer, it would be a better idea to move the solution in this answer and mark it as accepted.
    – Diana
    Mar 23, 2021 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.