|
1 | 1 | <?php |
2 | 2 |
|
3 | | -$config = array( |
4 | | - 'servers' => array( |
5 | | - array( |
6 | | - 'name' => getenv('VIRTUAL_HOST'), // Optional name. |
7 | | - 'host' => 'global-redis', |
8 | | - 'port' => 6379, |
9 | | - 'filter' => '*', |
10 | | - 'scheme' => 'tcp', // Optional. Connection scheme. 'tcp' - for TCP connection, 'unix' - for connection by unix domain socket |
11 | | - 'path' => '' // Optional. Path to unix domain socket. Uses only if 'scheme' => 'unix'. Example: '/var/run/redis/redis.sock' |
| 3 | +include 'config.sample.inc.php'; |
12 | 4 |
|
13 | | - // Optional Redis authentication. |
14 | | - //'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server. |
15 | | - ), |
| 5 | +$admin_user = getenv('ADMIN_USER'); |
| 6 | +$admin_pass = getenv('ADMIN_PASS'); |
16 | 7 |
|
17 | | - /*array( |
18 | | - 'host' => 'localhost', |
19 | | - 'port' => 6380 |
20 | | - ),*/ |
21 | | - |
22 | | - /*array( |
23 | | - 'name' => 'local db 2', |
24 | | - 'host' => 'localhost', |
25 | | - 'port' => 6379, |
26 | | - 'db' => 1, // Optional database number, see http://redis.io/commands/select |
27 | | - 'databases' => 1, // Optional number of databases (prevents use of CONFIG command). |
28 | | - 'filter' => 'something:*', // Show only parts of database for speed or security reasons. |
29 | | - 'seperator' => '/', // Use a different seperator on this database (default uses config default). |
30 | | - 'flush' => false, // Set to true to enable the flushdb button for this instance. |
31 | | - 'charset' => 'cp1251', // Keys and values are stored in redis using this encoding (default utf-8). |
32 | | - 'keys' => false, // Use the old KEYS command instead of SCAN to fetch all keys for this server (default uses config default). |
33 | | - 'scansize' => 1000 // How many entries to fetch using each SCAN command for this server (default uses config default). |
34 | | - ),*/ |
35 | | - ), |
36 | | - |
37 | | - |
38 | | - 'seperator' => ':', |
39 | | - |
40 | | - |
41 | | - // Uncomment to show less information and make phpRedisAdmin fire less commands to the Redis server. Recommended for a really busy Redis server. |
42 | | - //'faster' => true, |
43 | | - |
44 | | - |
45 | | - // Uncomment to enable HTTP authentication |
46 | | - /*'login' => array( |
47 | | - // Username => Password |
48 | | - // Multiple combinations can be used |
49 | | - 'admin' => array( |
50 | | - 'password' => 'adminpassword', |
51 | | - ), |
52 | | - 'guest' => array( |
53 | | - 'password' => '', |
54 | | - 'servers' => array(1) // Optional list of servers this user can access. |
55 | | - ) |
56 | | - ),*/ |
| 8 | +if (!empty($admin_user)) { |
| 9 | + $config['login'] = array( |
| 10 | + $admin_user => array( |
| 11 | +'password' => $admin_pass, |
| 12 | +), |
| 13 | +); |
| 14 | +} |
57 | 15 |
|
58 | | - // Use HTML form/cookie-based auth instead of HTTP Basic/Digest auth |
59 | | - 'cookie_auth' => false, |
| 16 | +$config['servers'] = array(); |
60 | 17 |
|
| 18 | +$prefix = 'REDIS_'; |
61 | 19 |
|
62 | | - /*'serialization' => array( |
63 | | - 'foo*' => array( // Match like KEYS |
64 | | - // Function called when saving to redis. |
65 | | - 'save' => function($data) { return json_encode(json_decode($data)); }, |
66 | | - // Function called when loading from redis. |
67 | | - 'load' => function($data) { return json_encode(json_decode($data), JSON_PRETTY_PRINT); }, |
68 | | - ), |
69 | | - ),*/ |
| 20 | +$server_name = getenv($prefix . 'NAME'); |
| 21 | +$server_host = getenv($prefix . 'HOST'); |
| 22 | +$server_port = getenv($prefix . 'PORT'); |
| 23 | +$server_auth = getenv($prefix . 'AUTH'); |
70 | 24 |
|
| 25 | +if (empty($server_host)) { |
| 26 | +$server_host = ""; |
| 27 | +} |
71 | 28 |
|
72 | | - // You can ignore settings below this point. |
| 29 | +if (empty($server_name)) { |
| 30 | +$server_name = $server_host; |
| 31 | +} |
73 | 32 |
|
74 | | - 'maxkeylen' => 100, |
75 | | - 'count_elements_page' => 100, |
| 33 | +if (empty($server_auth)) { |
| 34 | +$server_auth = ""; |
| 35 | +} |
76 | 36 |
|
77 | | - // Use the old KEYS command instead of SCAN to fetch all keys. |
78 | | - 'keys' => false, |
| 37 | +if (empty($server_port)) { |
| 38 | +$server_port = 6379; |
| 39 | +} |
79 | 40 |
|
80 | | - // How many entries to fetch using each SCAN command. |
81 | | - 'scansize' => 1000 |
| 41 | +$config['servers'][] = array( |
| 42 | +'name' => $server_name, |
| 43 | +'host' => $server_host, |
| 44 | +'port' => $server_port, |
| 45 | +'filter' => '*', |
82 | 46 | ); |
83 | 47 |
|
84 | | -?> |
| 48 | +if (!empty($server_auth)) { |
| 49 | +$config['servers'][0]['auth'] = $server_auth; |
| 50 | +} |
0 commit comments