Want more timely Centmin Mod News Updates?
Become a Member

Nginx Need Help With Nginx Rewrite On Centmin

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by skringjer, Jan 6, 2021.

Tags:
  1. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    5:26 AM
    Please fill in any relevant information that applies to you:
    • CentOS Version: CentOS 7
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: 1.19.1
    • PHP Version Installed: 7.4
    • MariaDB MySQL Version Installed: 7.3.18
    • When was last time updated Centmin Mod code base ? : Auto Updates
    • Persistent Config:
      Code (Text):
      LETSENCRYPT_DETECT='y'
      

    Greetings everyone, since Centmin nginx rewrites work a bit differently and me having no idea how to fix it. @eva2000 made this rewrite for me a while ago,
    Code:
    location ~ [^/]\.php(/|$) {
    #  include /usr/local/nginx/conf/503include-only.conf;
    #    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-e $request_filename) {
            rewrite ^/(.*) /index.php?_page_url=$1 last;
        }
        fastcgi_keep_conn on;
        fastcgi_pass dft_php;
        #fastcgi_pass   127.0.0.1:9000;
        #fastcgi_pass   unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
    But now the script i use has changed / updated and uses different rewrites, these ones
    Code:
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
            if (!-e $request_filename) { rewrite ^/(.*) /index.php?_page_url=$1 last; }
            fastcgi_pass 127.0.0.1:9001;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
            include fastcgi_params;
        }
    
         #location / {
            if (!-e $request_filename) {
                rewrite ^/(.*) /index.php?_page_url=$1 last;
            }
         #}
    
        location /files/ {
            internal;
        }
    
        # these locations would be hidden by .htaccess normally
        location /logs/ {
            deny all;
        }
    I dont know how to rewrite them properly, because my site is giving 502 Bad Gateway due to this, and in the error logs i have this
    Code:
    2021/01/05 18:19:08 [error] 8896#8896: *1578 connect() failed (111: Connection refused) while connecting to upstream, client: 39.110.209.143, server: domain.com, request: "GET /favicon.ico HTTP/2.0", upstream: "fastcgi://127.0.0.1:9001", host: "domain.com", referrer: "https://domain.com/fccN"
    The write that George did for me are placed in a custom php conf file php-custom.conf

     
  2. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    5:26 AM
    I think i fixed the issue, i had to uncomment the above location block