0

I installed dokuwiki and the farmer plugin today on my webserver running Nginx. Unfortunately, all of the documentation is for Apache, and i'm not good enough with figuring this stuff out to get this on my own. Scoured the web and all i've found is a question asking about using URL rewriting after the FQDN. My want is to setup the farm to build each child under sub.domain.com, so wiki.sub.domain.com. I feel like this shouldn't be as hard as it's proving to be, but... As it stands, the plugin does correctly build the subdomain address, but it doesn't properly direct. i have a server block in sites-available that does the normal redirecting, providing access to the farmer. So the question, given https://www.dokuwiki.org/farms and https://www.dokuwiki.org/plugin:farmer , is how to correctly build the server block with *.sub.domain.com as the FQDN built by the plugin? What do i need to put in for redirecting or rewriting? i have a DNS A entry with *.sub that i'm pretty sure should properly point, but i know it won't work without the rewriting.

server {
        #listen 80;
        #listen [::]:80;

        listen 443 ssl;
    listen [::]:443 ssl;

        ssl_certificate /path/to.crt;
        ssl_certificate_key /path/to.key;

        ssl_ciphers HIGH:!aNULL:!MD5;

        root /path/to/root/html;

        server_name sub.domain.com;

        index doku.php;

        client_max_body_size 1024M;
        client_body_timeout 60;

       #Support for X-Accel-Redirect
        location ~ ^/data/ { internal ; }

        location ~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$ {
        expires 365d;
        }

        location / { try_files $uri $uri/ @dokuwiki; }

        location @dokuwiki {
                # rewrites "doku.php/" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki config page
                rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
                rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
                rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
                rewrite ^/(.*) /doku.php?id=$1&$args last;
        }

       location ~ \.php$ {
                try_files $uri $uri/ /doku.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param REDIRECT_STATUS 200;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

        }

        location ~ /(conf|bin|inc)/ { deny all; }
        location ~ /install.php { deny all; }
        location ~ /data/ { internal; }
}

Anybody got any ideas? i don't know where to start at this point.

0

You need to understand how DokuWiki handle animals.

For creating an animal at animal.sub.domain.com,

You need to define the settings Base Domain for subdomain Animals in farming/configuration as sub.domain.com.

Next, Add a new animal

Define the Animal Name / Domain as animal1

Now, Dokuwiki points the animal1 to animal1.sub.domain.com

I tested this on a nginx server, it points to the domain correctly.

Additionally, if you are using SSL, you should redirect your http server to https for security purpose.

server {
    listen 80;
    server_name  sub.domain.com;
    return 301 https://$host$request_uri;
}

My sub.domain.com.confnginx settings are below. It also includes the location blocks for handling nice url rewrites.

server {
    listen 80;
    server_name  sub.domain.com;
    return 301 https://$host$request_uri;
    autoindex off;    
}

# For ssl
server {
    ssl on;
    ssl_certificate /etc/letsencrypt/live/sub.domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/sub.domain.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_stapling on;
    ssl_stapling_verify on;
    add_header Strict-Transport-Security max-age=15768000;
    client_max_body_size 20M;
    client_body_buffer_size 128k;
    default_type  application/octet-stream;

    listen 443;
    server_name  sub.domain.com;

    root /var/www/html/wiki;

    # For ACME challenge
    location ~ /.well-known {
        allow all;
    }

  location ~ ^/! {
        rewrite ^/!(.*?)/(.*) /$2?$args&animal=$1 last;
        rewrite ^/!(.*)$      /?animal=$1 last;

        }


    location / {
        index doku.php;
         try_files $uri $uri/ @dokuwiki;

    }

 location ~ ^/lib.*\.(gif|png|ico|jpg)$ {
    expires 30d;
  }


   location ~ /farm {
        index doku.php;
        autoindex on;
        rewrite ^/farm/?([^/]+)/(.*) /wiki/$2?animal=$1;
        rewrite ^/farm/?([^/]+)$ /wiki/?animal=$1;

        }


 location @dokuwiki {
        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
        rewrite ^/(.*) /doku.php?id=$1&$args last;

    }

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

  location ~ /(data|conf|bin|inc)/ {
        deny all;
    }


}
  • Thank you very much for the response!! i greatly appreciate the starting point. As it stands, the farm is no longer redirecting to the original wiki, which is progress. Now, however, it is redirecting to entire other subdomains of the site. i don't really know how to try to parse what needs to be changed at this point, but i did go in and change the ~ /farm directory to /farmanimals, same in the following lines? Ideas? – kitkat Jan 11 at 5:03
  • Can you give an example, of an error you facing? Do you mean that sub.domain.com/farm/ does not redirect to the main wiki? Which entire subdomain is it redirecting? – Ranjit Singh Jan 16 at 5:40
  • So after editing using items from the example you provided above, if I build a new wiki, say "abc", it shows that the redirect should be "abc.sub.domain.com", but when i click on it, it redirects to say, sub1.domain.com. – kitkat Jan 17 at 3:02
  • you also need to define Farmer Host Name as sub.domain.com in farming > configuration. Ater changing, clear your cache and create a new animal. – Ranjit Singh Jan 17 at 10:26
  • I have cleared the cache and defined the host name in the config. It is still redirecting to sub1.domain.com, which is an entirely different site on the server. – kitkat Jan 25 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.