Nginx Config cause ERROR 500

Discussion in 'Installation/Configuration' started by yasine, Jul 20, 2024.

  1. yasine

    yasine Member

    I have WordPress website running wpml with 2 languages fr (french , default languauge ) and en ( english as a secondary language ),
    it works fine for the en version, but did not work for the french version just the main domain https://preprod.kodingschools.com/fr/, but others works just fine for example : https://preprod.kodingschools.com/fr/dashboard , ... all works
    hers is my nginx Directives input from the ISPConfig,
    Code:
    location / {
         try_files $uri $uri/ /index.php?q=$uri&$args;
     }
    
    location = /fr/ {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    set $skip_cache 0;
    set $always_cache 0;
    
    # Pages to always cache even if user is logged in
        if ($request_uri ~* "/faq.*|/contact.*|/contact-it.*|/contact-consulting.*|/student-textbook.*|/manuel-de-leleve.*|/textbook-en.*|/textbook-fr.*|/manuel-fr.*|/manuel-en.*|/conditions-dutilisation.*|/terms-of-service.*|/abonnement.*|/subscription.*") {
            set $always_cache 1;
        }
    
        # Exclude POST requests from cache
        if ($request_method = POST) {
            set $skip_cache 1;
        }
    
        # Exclude URLs with query strings from cache
        if ($query_string != "") {
            set $skip_cache 1;
        }
    
        # WooCommerce exclusions
        if ($request_uri ~* "/paiement.*|/cart.*|/panier.*|/checkout.*|/addons.*") {
            set $skip_cache 1;
        }
    
        # Exclude specific URL paths from cache
        if ($request_uri ~* "^/(\.well-known|wp-admin|xmlrpc\.php|wp-.+\.php|feed|index\.php|wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php|sitemap(_index)?\.xml|[a-z0-9_-]+-sitemap[0-9]+\.xml)") {
            set $skip_cache 1;
        }
    
        # Exclude requests with specific cookies from cache, unless it's a specific page to always cache
        if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
            set $skip_cache 1;
        }
    
        # Override skip_cache for always_cache pages
        if ($always_cache = 1) {
            set $skip_cache 0;
        }
    
    location @php { ##merge##
        fastcgi_cache {DOMAIN};
        fastcgi_cache_valid 200 301 302 2h;
        fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
        fastcgi_cache_min_uses 1;
        fastcgi_cache_lock on;
        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        add_header X-FastCGI-Cache $upstream_cache_status;
        add_header X-Powered-By "kodingschools";
    }
    and this is the entire vhost config file :

    Code:
    root@cloud:/etc/nginx/sites-available# cat preprod.kodingschools.com.vhost
    fastcgi_cache_path /var/www/clients/client1/web3/web/cache levels=1:2 keys_zone=preprod.kodingschools.com:200m max_size=10g inactive=2h use_temp_path=off;
    
    server {
            listen *:80;
            listen [::]:80;
            listen *:443 ssl http2;
    
            ssl_protocols TLSv1.3 TLSv1.2;
            listen [::]:443 ssl http2;
            ssl_certificate /var/www/clients/client1/web3/ssl/preprod.kodingschools.com-le.crt;
            ssl_certificate_key /var/www/clients/client1/web3/ssl/preprod.kodingschools.com-le.key;
    
            server_name preprod.kodingschools.com www.preprod.kodingschools.com;
    
            root   /var/www/preprod.kodingschools.com/web/;
                    disable_symlinks if_not_owner from=$document_root;
    
            if ($scheme != "https") {
                rewrite ^(?!/\.well-known/acme-challenge)/ https://$http_host$request_uri? permanent;
            }
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml standard_index.html;
    
    
            error_page 400 /error/400.html;
            error_page 401 /error/401.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 405 /error/405.html;
            error_page 500 /error/500.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            recursive_error_pages on;
            location = /error/400.html {
    
                internal;
                auth_basic off;
            }
            location = /error/401.html {
    
                internal;
                auth_basic off;
            }
            location = /error/403.html {
    
                internal;
                auth_basic off;
            }
            location = /error/404.html {
    
                internal;
                auth_basic off;
            }
            location = /error/405.html {
    
                internal;
                auth_basic off;
            }
            location = /error/500.html {
    
                internal;
                auth_basic off;
            }
            location = /error/502.html {
    
                internal;
                auth_basic off;
            }
            location = /error/503.html {
    
                internal;
                auth_basic off;
            }
    
            error_log /var/log/ispconfig/httpd/preprod.kodingschools.com/error.log;
            access_log /var/log/ispconfig/httpd/preprod.kodingschools.com/access.log combined;
    
            location ~ /\. {
                            deny all;
            }
    
            location ^~ /.well-known/acme-challenge/ {
                            access_log off;
                            log_not_found off;
                            auth_basic off;
                            root /usr/local/ispconfig/interface/acme/;
                            autoindex off;
                            index index.html;
                            try_files $uri $uri/ =404;
            }
    
            location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            }
    
            location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
            }
    
            location /stats/ {
    
                index index.html index.php;
                auth_basic "Members Only";
                auth_basic_user_file /var/www/clients/client1/web3/web//stats/.htpasswd_stats;
                add_header Content-Security-Policy "default-src * 'self' 'unsafe-inline' 'unsafe-eval' data:;";
            }
    
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files /cda579e7798f1c5f3c48c0fa0d3a6428.htm @php;
            }
    
            location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php8.2-fpm/web3.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
                fastcgi_cache preprod.kodingschools.com;
                fastcgi_cache_valid 200 301 302 2h;
                fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
                fastcgi_cache_min_uses 1;
                fastcgi_cache_lock on;
                fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
                fastcgi_cache_bypass $skip_cache;
                fastcgi_no_cache $skip_cache;
                add_header X-FastCGI-Cache $upstream_cache_status;
                add_header X-Powered-By "kodingschools";
            }
    
            location /cgi-bin/ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                root /var/www/clients/client1/web3;
                gzip off;
                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
                fastcgi_index index.cgi;
                fastcgi_param DOCUMENT_ROOT /web;
                fastcgi_param HOME /web;
                fastcgi_param SCRIPT_FILENAME /web$fastcgi_script_name;
                fastcgi_intercept_errors on;
            }
    
    
    
            location / {
                 try_files $uri $uri/ /index.php?q=$uri&$args;
                    auth_basic "Members Only";
                    auth_basic_user_file /var/www/clients/client1/web3/web/.htpasswd;
    
                    location ~ \.php$ {
                        try_files /cda579e7798f1c5f3c48c0fa0d3a6428.htm @php;
                    }
            }
    
            location = /fr/ {
                try_files $uri $uri/ /index.php?$query_string;
            }
    
            set $skip_cache 0;
            set $always_cache 0;
    
                if ($request_uri ~* "/faq.*|/contact.*|/contact-it.*|/contact-consulting.*|/student-textbook.*|/manuel-de-leleve.*|/textbook-en.*|/textbook-fr.*|/manuel-fr.*|/manuel-en.*|/conditions-dutilisation.*|/terms-of-service.*|/abonnement.*|/subscription.*") {
                    set $always_cache 1;
                }
    
                if ($request_method = POST) {
                    set $skip_cache 1;
                }
    
                if ($query_string != "") {
                    set $skip_cache 1;
                }
    
                if ($request_uri ~* "/paiement.*|/cart.*|/panier.*|/checkout.*|/addons.*") {
                    set $skip_cache 1;
                }
    
                if ($request_uri ~* "^/(\.well-known|wp-admin|xmlrpc\.php|wp-.+\.php|feed|index\.php|wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php|sitemap(_index)?\.xml|[a-z0-9_-]+-sitemap[0-9]+\.xml)") {
                    set $skip_cache 1;
                }
    
                if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                    set $skip_cache 1;
                }
    
                if ($always_cache = 1) {
                    set $skip_cache 0;
                }
    
    
    
    }
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the error.log of the website. Also turn off custom error pages in the website as this 500 error can be just a notice from Wordpress and not a real 500 error of the web server.
     
    yasine and ahrasis like this.

Share This Page