Nginx and NExtGen (4 posts)

  1. cheezitman
    Posted 3 years ago #

    I'm running a WordPress MU site using an Nginx php-fpm backend. It works great except now that I'm trying to use the NextGen Gallery Plugin here.

    Regular images work fine, but NextGen uploads the pictures fine, nginx isn't serving them. Any suggestions on where to look?

    My Nginx Config is below:

    # WordPress multisite subdirectory rules.
    # Designed to be included in any server {} block.

    # This order might seem weird - this is attempted to match last if rules below fail.
    # http://wiki.nginx.org/HttpCoreModule
    location / {
    try_files $uri $uri/ /index.php?$args;

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    # Directives to send expires headers and turn off 404 error logging.
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|mov|mp4|avi|doc|docx|pdf)$ {
    expires 48h;
    log_not_found off;

    # Pass uploaded files to wp-includes/ms-files.php.
    rewrite /files/$ /index.php last;

    # For multisite: Use a caching plugin/script that creates symlinks to the correct subdirectory structure to get some performance gains.
    set $cachetest "$document_root/wp-content/cache/ms-filemap/${host}${uri}";
    if ($uri ~ /$) {
    set $cachetest "";
    if (-f $cachetest) {
    # Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule.
    rewrite ^ /wp-content/cache/ms-filemap/${host}${uri} break;

    if ($uri !~ wp-content/plugins) {
    rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;

    # Uncomment one of the lines below for the appropriate caching plugin (if used).
    # include global/wordpress-ms-subdir-wp-super-cache.conf;
    # include global/wordpress-ms-subdir-w3-total-cache.conf;

    # Rewrite multisite '.../wp-.*' and '.../*.php'.
    if (!-e $request_filename) {
    rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
    rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;

    # Pass all .php files onto a php-fpm/php-fcgi server.
    location ~ \.php$ {
    # Zero-day exploit defense.
    # http://forum.nginx.org/read.php?2,88845,page=3
    # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
    # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
    try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    # fastcgi_intercept_errors on;

  2. Pothi
    Posted 3 years ago #

    Please post your nginx configuration from pastebin or something similar.

    Did the Nginx logs show any clue?

  3. cheezitman
    Posted 3 years ago #

    I'm not seeing anything in the error log.

    I do see things like this in the access log:

    My nginx.conf file:

    My sites-enabled file:

    My wordpress config file:

  4. Pothi
    Posted 3 years ago #

    I could not reproduce the issue (404 error) while using my site's nginx configuration and then your site's nginx configuration. Basically, there is nothing wrong with your site's nginx configuration, even though it could be improved by reducing the number of if conditions.

    So, your issue is similar to someone already experienced here (no solutions, yet). Please note the gallery works fine for me (as previously mentioned), but it could be because I tested it using a demo WP multisite. I'm sorry, I couldn't help further.

Topic Closed

This topic has been closed to new replies.

About this Topic