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;
        }
    }
0

Okay nevermind, I figured it out now

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 Botean Mar 22 at 9:31
  • I did that directly in the first post – David Mar 23 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 Botean Mar 23 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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