mecha-cms / mecha

Minimalist content management system.

Home Page:https://mecha-cms.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nginx Support (Contribution)

bet0x opened this issue · comments

Make sure that your issue is reproducible by doing the following tasks

  • I am using application packages whose source code is not optimized for production (source code is not minified).
  • I have activated the test mode by changing the TEST constant value to true in the .\index.php file.
  • I have made sure that there are files named error or error-x or error-y in the .\engine\log folder.

What installation method did you use?

Composer

Describe your issue in the field below

Hello all,

I didn't found the documentation on git to place a PR but here it is the code block for Nginx to get it working and secured too:

location / {
    try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
     fastcgi_intercept_errors on;
     include        fastcgi_params;
     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     fastcgi_pass unix:/run/php-fpm/www.sock;
}

location ~ /\. { deny all; }

location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
}

Package version

Development version (package on the main branch)

Package version number

3.0.0

What browsers are you seeing the problem on?

Firefox

Error logs of the core application if any

No response

Error log of the extension if any

No response

Error log of the layout if any

No response

General error logs if any (if the application fails to set a custom error log path, then the error log will usually appear in this location)

No response

Thanks a lot! Will add it to the site documentation 👍

@bet0x does this part prevent the root .\index.php file from public access?

location ~ \.php$ {
    fastcgi_intercept_errors on;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php-fpm/www.sock;
}

The root .\index.php must be accessible.

Doesn't prevent access at all. It just works. I will apply a few fixes on other paths later but so far everything runs smoothly.

Okay, I will move this issue to the discussion later, so I can properly reference it. Discussions will also allow for more user inputs.