Следующая версия | Предыдущая версия |
wiki:farms:advanced [2025/01/15 20:11] – создано - внешнее изменение 127.0.0.1 | wiki:farms:advanced [2025/01/15 21:55] (текущий) – [Запуск фермы за обратным прокси-сервером] vladpolskiy |
---|
====== Advanced Farm Setups and Tips ====== | ====== Расширенные настройки фермы и советы ====== |
| |
FIXME Most of the [[tips:farm|old farm documentation]] which isn't covered in the [[:farms|new farm documentation]] should be added here. | FIXME Большую часть [[tips:farm|старой документации фермы]], которая не охвачена [[wiki:farms|новой документацией фермы]], следует добавить сюда. |
| |
The following sections assume a setup similar to the one described on [[:farms]]. | В следующих разделах предполагается установка, аналогичная той, что описана на [[wiki:farms|фермах]]. |
| |
===== CLI tools ===== | ===== CLI tools ===== |
| |
If you want to use the [[:cli|command line tools]] you only need to set the animal name in the ''animal'' environment variable. For example if you want to execute ''bin/indexer.php'' for the "foo" animal, you can use ''animal=foo bin/indexer.php''. | CLI-инструменты [[wiki:cli| инструменты командной строки]] вам нужно только задать имя животного в ''animal'' переменной окружения. Например, если вы хотите выполнить ''bin/indexer.php'' для животного "foo" вы можете использовать ''animal=foo bin/indexer.php''. |
| |
===== Setting defaults and restricting options ===== | ===== Установка значений по умолчанию и ограничение опций ===== |
| |
You can add additional configuration files for the default values that should be used in animals and for restricting certain configuration options. If you add the following code to the end of ''inc/preload.php'', the main configuration file of the farmer will be used as default for all animals and the protected file of the farmer will be used as the last protected file for all animals which means that animals then can't change these options. This could be used in order to disable certain options like [[config:phpok]] if you don't trust the animal admin. | Вы можете добавить дополнительные файлы конфигурации для значений по умолчанию, которые должны использоваться в животных, и для ограничения определенных параметров конфигурации. Если вы добавите следующий код в конец ''inc/preload.php'', основной файл конфигурации фермера будет использоваться как файл по умолчанию для всех животных, а защищенный файл фермера будет использоваться как последний защищенный файл для всех животных, что означает, что животные не смогут изменять эти параметры. Это может быть использовано для отключения определенных параметров, таких как [[wiki:config:phpok]] если вы не доверяете администратору животных. |
| |
<file php> | <file php> |
</file> | </file> |
| |
Note that these changes also affect the farmer if it can be accessed. This will break the configuration manager in the farmer as it assumes that all changed values are defaults and will remove them from the configuration. | Обратите внимание, что эти изменения также влияют на фермера, если к нему есть доступ. Это сломает менеджер конфигурации в фермере, поскольку он предполагает, что все измененные значения являются значениями по умолчанию, и удалит их из конфигурации. |
| |
You can use similar changes for the plugins cascade in order to define a set of plugins that are enabled by default or a set of plugins that must or must not be enabled. | Аналогичные изменения можно использовать для каскада плагинов, чтобы определить набор плагинов, которые включены по умолчанию, или набор плагинов, которые должны или не должны быть включены. |
| |
You can of course also completely change the configuration cascade, you can find the default configuration cascade that is used in farms at the end of ''inc/farm.php''. | Конечно, вы также можете полностью изменить каскад конфигурации, каскад конфигурации по умолчанию, который используется в фермах, вы можете найти в конце ''inc/farm.php''. |
| |
===== Disabling access to the farmer ===== | ===== Отключение доступа к фермеру ===== |
| |
If you want to disable access to the farmer you can add something like | Если вы хотите отключить доступ к фермеру, вы можете добавить что-то вроде |
| |
<code php> | <code php> |
</code> | </code> |
| |
at the end of ''inc/preload.php'' (after the inclusion of ''farm.php''). | в конце ''inc/preload.php'' (после включения ''farm.php''). |
| |
===== Central user management ===== | ===== Централизованное управление пользователями ===== |
| |
If some or all of your animals shall share the users you can do that not just by using the same external authentication but also with the default user management of DokuWiki by setting the path to the user list to the same location at the end of ''inc/preload.php'': | Если некоторые или все ваши животные должны иметь общих пользователей, вы можете сделать это не только с помощью той же внешней аутентификации, но и с помощью управления пользователями DokuWiki по умолчанию, указав путь к списку пользователей в том же месте в конце ''inc/preload.php'': |
| |
<code php> | <code php> |
</code> | </code> |
| |
If you want to do that just for some animals you can of course simply add a condition based on the value of ''DOKU_CONF''. | Если вы хотите сделать это только для некоторых животных, вы, конечно, можете просто добавить условие, основанное на значении ''DOKU_CONF''. |
| |
===== Flexible .htaccess-based setups ===== | ===== Гибкие настройки на основе .htaccess ===== |
| |
Actually .htaccess-based setups can be a lot more flexible than the setups that is described on [[:farms]]. For these advanced setups your farm directory can and even should be outside the document root (the directory that is accessible from the web). If your farm directory is inside the document root you need to make sure that you properly protect each data directory (for example using .htaccess as it is done in a normal DokuWiki setup) as in these advanced setups they might not be automatically protected (depends on the rewrite conditions you use). | На самом деле настройки на основе .htaccess могут быть намного более гибкими, чем настройки, описанные на [[wiki::farms|фермах]]. Для этих расширенных настроек ваш каталог фермы может и даже должен быть вне корня документов (каталога, доступного из Интернета). Если ваш каталог фермы находится внутри корня документов, вам нужно убедиться, что вы должным образом защищаете каждый каталог данных (например, используя .htaccess, как это делается в обычной настройке DokuWiki), так как в этих расширенных настройках они могут не быть автоматически защищены (зависит от используемых вами условий перезаписи). |
| |
In order to make the animals accessible as in the standard setup you can create a second farm directory inside the document root with a .htaccess file and no animal directories. You can also add ''RewriteCond'' statements as in the example below in order to prevent redirect loops. Then your animals can be in the domain's root directory, i.e. you can have ''example.com/animal1/'' for animal "animal1" and ''example.com/dokuwiki/'' for the farmer. | Чтобы сделать животных доступными, как в стандартной настройке, вы можете создать второй каталог фермы внутри корня документа с файлом .htaccess и без каталогов животных. Вы также можете добавить ''RewriteCond'' операторы, как в примере ниже, чтобы предотвратить циклы перенаправления. Тогда ваши животные могут быть в корневом каталоге домена, т. е. вы можете иметь ''example.com/animal1/'' для животного ''animal1'' и ''example.com/dokuwiki/'' для фермера. |
| |
<code apache .htaccess> | <code apache .htaccess> |
Options +FollowSymLinks | Options +FollowSymLinks |
</code> | </code> |
==== More than one domain ==== | ==== Более одного домена ==== |
| |
If you can use [[wp>symbolic link|symbolic links]] you can easily link a directory in each domain's document root to the farmer and specify this directory in the rewrite rules. | Если вы можете использовать [[wp>symbolic link|символические ссылки]] вы можете легко связать каталог в корневом каталоге документов каждого домена с фермером и указать этот каталог в правилах перезаписи. |
| |
==== Custom paths ==== | ==== Пользовательские пути ==== |
| |
If you don't want to have all animals in one directory you can simply create a .htaccess file for each animal. In this .htaccess file you can specify the animal name. | Если вы не хотите, чтобы все животные были в одном каталоге, вы можете просто создать файл .htaccess для каждого животного. В этом файле .htaccess вы можете указать имя животного. |
| |
<code apache .htaccess> | <code apache .htaccess> |
</code> | </code> |
| |
The ''RewriteCond'' statements prevent redirect loops when your farmer directory is inside the animal directory. That way you can also put an animal in the root directory of a domain. | Операторы ''RewriteCond'' предотвращают циклы перенаправления, когда ваш каталог фермера находится внутри каталога животных. Таким образом, вы также можете поместить животное в корневой каталог домена. |
| |
===== Running a farm behind a reverse proxy ===== | ===== Запуск фермы за обратным прокси-сервером ===== |
| |
This is when you set up your farm on a backend server (e.g. http://11.22.33.44) and present your wikis to the world via a front-end Apache server (e.g. http://www.example.com). | Это происходит, когда вы настраиваете свою ферму на внутреннем сервере (например http://11.22.33.44) и представляете свои вики-ресурсы миру через фронтенд-сервер Apache (например, http://www.example.com). |
| |
Firstly set up the farm on the backend as per the [[:farms|standard docs]]. | Сначала настройте ферму на сервере в соответствии со [[wiki:farms|стандартной документацией]]. |
| |
In my case I've decided to put all my DokuWiki files into one location to keep them separate from any other sites running on the backend server: | В моем случае я решил поместить все файлы DokuWiki в одно место, чтобы отделить их от других сайтов, работающих на внутреннем сервере: |
| |
''/var/www/wikis/'' -- The root of my DokuWiki installation. | ''/var/www/wikis/'' -- Корень моей установки DokuWiki. |
| |
Therefore my farm setup is: | Итак, моя ферма имеет следующую конфигурацию: |
| |
* ''/var/www/wikis/dokuwiki'' -- the DokuWiki engine, this needs to be accessible from the web | * ''/var/www/wikis/dokuwiki''– движок DokuWiki, он должен быть доступен из Интернета |
* ''/var/www/wikis/farm'' -- the DokuWiki farm directory which contains all the animals | * ''/var/www/wikis/farm''– каталог ферм DokuWiki, содержащий всех животных |
* ''/var/www/wikis/farm/bear'' -- my first wiki which is about bears | * ''/var/www/wikis/farm/bear''– моя первая вики о медведях |
| |
On the backend server my wiki about bears (once fully setup) will be available at the following address: http://11.22.33.44/wikis/farm/bear | На внутреннем сервере моя вики о медведях (после полной настройки) будет доступна по следующему адресу http://11.22.33.44/wikis/farm/bear |
| |
However, on the frontend server I want to present my wiki with the following address (notice I've chosen to drop the 's' from 'wikis' in this URL): http://www.example.com/wiki/bear | Однако на сервере frontend я хочу представить свою вики по следующему адресу (обратите внимание, что я решил убрать «s» из «wikis» в этом URL ): http://www.example.com/wiki/bear |
| |
Using the .htaccess type of setup, I set up ''/var/www/wikis/farm/.htaccess'' with the following code: | Используя тип настройки .htaccess, я настроил его ''/var/www/wikis/farm/.htaccess'' с помощью следующего кода: |
| |
<code apache .htaccess> | <code apache .htaccess> |
</code> | </code> |
| |
Under ''/var/www/wikis/farm/bear/conf'' I then edit **local.protected.php** like so (note: this uses the front-end address): | Затем ''/var/www/wikis/farm/bear/confя'' редактирую **local.protected.php** следующим образом (примечание: здесь используется адрес интерфейса): |
| |
<code php local.protected.php> | <code php local.protected.php> |
</code> | </code> |
| |
Therefore I use [[http://httpd.apache.org/docs/2.2/mod/mod_proxy.html|Apache's mod_proxy]] and set up the config in **httpd.conf** on the front-end server: | Поэтому я использую [[http://httpd.apache.org/docs/2.2/mod/mod_proxy.html|Apache's mod_proxy]] и настраиваю конфигурацию в **httpd.conf** на сервере front-end: |
| |
<code apache httpd.conf> | <code apache httpd.conf> |
</code> | </code> |
| |
This means that any animals in my farm will always be reverse proxied from the desired front-end address. | Это означает, что все животные на моей ферме всегда будут проходить обратный прокси-сервер с желаемого адреса интерфейса. |
| |
This works very well until you perform certain actions (e.g. login, logout, saving edits etc.) Due to the fact that the DokuWiki engine does a redirect at these points, the end-user's browser is sent a HTTP 302 header containing the following: | Это работает очень хорошо, пока вы не выполните определенные действия (например, вход в систему, выход из системы, сохранение изменений и т. д.). Поскольку движок DokuWiki выполняет перенаправление в этих точках, браузеру конечного пользователя отправляется заголовок HTTP 302, содержащий следующее: |
| |
''Location: http://11.22.33.44/wiki/bear/doku.php?id=blahblahblah'' | ''Location: http://11.22.33.44/wiki/bear/doku.php?id=blahblahblah'' |
| |
Of course there is no page at this location on the backend server and the result is a HTTP 404 Page Not Found error message in the user's browser. | Конечно, на внутреннем сервере по этому адресу нет страницы, и в результате в браузере пользователя появляется сообщение об ошибке HTTP 404 «Страница не найдена». |
| |
The remedy is to use [[http://httpd.apache.org/docs/2.2/mod/mod_headers.html|Apache's mod_headers]]. We amend our code block in **httpd.conf** like so: | Средство — использовать [[http://httpd.apache.org/docs/2.2/mod/mod_headers.html|Apache's mod_headers]]. Мы изменяем наш блок кода в **httpd.conf** следующим образом: |
| |
<code apache httpd.conf> | <code apache httpd.conf> |