• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question drupal 8 in nginx-only mode

How did you alter the recipe to use it and what specifically were the errors you've encountered?
 
I altered the fastcgi_pass to the correct socket (copied from the Plesk-generated nginx.conf). Homepage works fine but paths underneath it results in a 404. It seems like the index.php is not called as entry point.
 
I have the same problem. Drupal 8 works fine with NGINX as proxy for Apache but switching to nginx in solo mode shows only the mainpage and results in error 404 when when going to any other sides of the whole page.
 
I'm also looking for a good config for drupal8/9 with php 7.3/php7.4

If nginx only is enabled, only the front-page loads.
All other pages give 404 plesk pages.

I used this WordPress code under additional nginx directives I at least got more pages showing.

if (!-e $request_filename) {
set $test P;
}
if ($uri !~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon|internal-nginx-static-location)) {
set $test "${test}C";
}
if ($test = PC) {
rewrite ^/(.*)$ /index.php?$1;
}

Unfortunately I still have trouble with /update.php going to a nginx 404 page

And if development maintenance page is enabled, I only get nginx 503 page and not drupals maintenance pages

In addition my drupal redis statistics status stays empty as well.

Overall the site is much faster.
 

Attachments

  • Screenshot_20200615-063431_Chrome.jpg
    Screenshot_20200615-063431_Chrome.jpg
    452.8 KB · Views: 1
Last edited:
I got a bit further yesterday as the above is only for wordpress

Unfortunately I is still face issues for 403/404 and maintenance 503 page that now come from ngnix insteade from drupal

And tailings / only are removed on frontpage but not on other pages like ../en/

Here my config, I'm using an enhance self compiled nginx VirtuBox/nginx-ee

If used u need to replace YOURDOMAIN to point to your install for

fastcgi_pass unix:/var/www/vhosts/system/YOURDOMAIN/php-fpm.sock;


Perhaps someone can help spot the error ;)


Code:
#Google Pagespped settings
pagespeed on;
pagespeed FileCachePath "/var/cache/nginx/";
pagespeed RewriteLevel OptimizeForBandwidth;
pagespeed RewriteLevel CoreFilters;

location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
    add_header "" "";
}

location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

#Cache Control Immutable
location ~* .(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ {
    etag on;
    if_modified_since exact;
    add_header Pragma "public";
    add_header Cache-Control "max-age=31536000, public";
}

# serve either Gzip or Brotli depending on the user's browser
location ~ ^/sites/.*/files/(css|js) { brotli_static on; gzip_static on; }

#gzip  Settings
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_static on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/plain text/xml;

# Brotli Settings
brotli on;
brotli_static on;
brotli_buffers 16 8k;
brotli_comp_level 6;
brotli_types *;

#location ~ / {
    #    index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
    #    try_files $uri $uri /index.php$is_args$args;
    #}

    location ~ / {
        # try_files $uri @rewrite; # For Drupal <= 6
        try_files $uri /index.php?$query_string; # For Drupal >= 7
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    #Drupal stuff

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ (^|/)\. {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Don't allow direct access to PHP files in the vendor directory.
    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }

    # Block access to scripts in site files directory
    location ~ ^/sites/[^/]+/files/.*\.php$ {
        deny all;
    }

    # Allow "Well-Known URIs" as per RFC 5785
    location ~* ^/.well-known/ {
        allow all;
    }

    # Fighting with Styles? This little gem is amazing.
    # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6

    location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
    try_files $uri @rewrite;
}

# Handle private files through Drupal. Private file's path can come
# with a language prefix.
location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
try_files $uri /index.php?$query_string;
}

# In Drupal 8, we must also match new paths where the '.php' appears in the middle, such as update.php/selection. The rule we use is strict, and only allows this pattern with the update.php front controller.
# This allows legacy path aliases in the form of log/index.php/legacy-path to continue to route to Drupal nodes. If you do not have any paths like that, then you might prefer to use a laxer rule, such as: location ~ \.php(/|$) {
    # The laxer rule will continue to work if Drupal uses this new URL pattern with front controllers other than update.php in a future release.

    location ~ '\.php$|^/update.php' {

        # Ensure the php file exists. Mitigates CVE-2019-11043
        #try_files $uri =404;
        try_files $uri $uri/ /index.php?q=$uri&$args;
        #fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        # Security note: If you're running a version of PHP older than the latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
        # See http://serverfault.com/q/627903/94922 for details.

        include fastcgi_params;

        # Block httpoxy attacks. See https://httpoxy.org/.
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;

        # PHP 7 socket location.
        fastcgi_pass unix:/var/www/vhosts/system/YOURDOMAIN/php-fpm.sock;
    }

    # Enforce clean URLs
    # Could be done with 301 for permanent or other redirect codes.
    if ($request_uri ~* "^(.*/)index\.php(.*)") {
        return 307 $1$2;
    }
 
Back
Top