2

I am attempting to setup multiple dokuwiki's but I am really struggling...

I can set up one with relative ease but I would like to make use of the farm concept ( https://www.dokuwiki.org/farms ). The downside is it is written for apache not nginx and equally I have not found any nginx guides.

I am unable to make use of vhost where this shall be deployed (I have test vhost locally and I can configure this) and thus the nginx equivalent of htaccess is required.

The problem appears to be around the "animal" rewrite

RewriteRule ^/?([^/]+)/(.*) /farmer/$2?animal=$1 [QSA]

RewriteRule ^/?([^/]+)$ /farmer/?animal=$1 [QSA]

becomes (within a relevant location).

rewrite ^/?([^/]+)/(.*) /farmer/$2?animal=$1;

rewrite ^/?([^/]+)$ /farmer/?animal=$1;

NOne of what I have tried works so I decided to step right back and follow the redirect tips ( https://www.dokuwiki.org/tips:redirect_farm ) and I am unable to produce a functioning Step 2: Setup the URL binding the testing of the redirect

This is my localhost.conf.

server { listen 80; server_name localhost; access_log

/var/log/nginx/localhost_access_log main; error_log

/var/log/nginx/localhost_error_log info; rewrite_log on; root

/var/www/localhost/htdocs; #location ~

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

location / { autoindex on; }

location /barn { #alias /var/www/localhost/htdocs/farmer/;

  rewrite ^/?([^/]+)/(.*) /farmer/$2?animal=$1;

      rewrite ^/?([^/]+)$ /farmer/?animal=$1;     }

}

http://localhost/barn does redirect to "farmer" and the debug logs show:

*1 rewritten data: "/farmer/", args: "animal=barn", client: 127.0.0.1, server: localhost, request: "GET /barn/ HTTP/1.1", host: "localhost"

the animal=barn part is the worry... equally http://localhost/barn/foo fails with 404 and the rewrite logs show:

rewritten data: "/farmer/foo", args: "animal=barn", client: 127.0.0.1, server: localhost, request: "GET /barn/foo HTTP/1.1", host: "localhost"

what I was expecting was animal=foo. Any advice as to how to correct the rewrite

1 Answer 1

0

Well I have sort of answered it...

/var/www/localhost/htdocs/farmer is the base dokuwiki /var/www/localhost/htdocs/barn is a directory holding my farm /var/www/localhost/htdocs/barn/cow is the 1st animal /var/www/localhost/htdocs/barn/duck is the 2nd animal

farmer/inc/preload.php is configured as per the tips:

if(!defined('DOKU_FARMDIR')) define('DOKU_FARMDIR', '/var/www/localhost/htdocs/barn');

cow/conf/local.protected.php is equally configured

$conf['basedir'] = '/barn/cow/';

duck/conf/local.protected.php is equally configured

$conf['basedir'] = '/barn/duck/';

now the nginx localhost.conf is configured such:

server {
    listen 80;
    server_name localhost;
    access_log /var/log/nginx/localhost_access_log main;
    error_log /var/log/nginx/localhost_error_log info;
    rewrite_log on;
    root /var/www/localhost/htdocs;

    location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; } # post-install lockdown

    location / {
        try_files $uri $uri/ doku.php @farmer;
        autoindex on;
        }
    location /cow {
        return 301 http://$host/barn/cow/doku.php;
        }

    location /duck {
        return 301 http://$host/barn/duck/doku.php;
        }


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

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

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;  
    }

}

I can navigate to http://localhost/farmer for base, http://localhost/cow (redirecting to http://localhost/bar/cow/doku.php, internally rewritten as http://localhost/farmer/?animal=cow) for 1st animal and the same for the 2nd.

I don't like aspects of the nginx chainloading but it works(tm)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .