Skip to content

Commit eb6ae88

Browse files
committed
#2: Support for Harbor's Harbor-Real-Ip header
1 parent 77d7b15 commit eb6ae88

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

wp-config-riotkit.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ function get_preferred_protocol ($url) {
2121
}
2222

2323
function wp_find_page_url() {
24+
/**
25+
* WP_PAGE_URL allows to customize the page url via environment variables
26+
*/
2427
if (isset($_SERVER['WP_PAGE_URL'])) {
2528
$vhost = get_virtual_host($_SERVER['WP_PAGE_URL']);
2629

2730
return get_preferred_protocol($vhost) . $vhost;
2831
}
2932

33+
/**
34+
* Integrates with RiotKit Harbor and with NGINX Proxy
35+
*/
3036
if (isset($_SERVER['VIRTUAL_HOST'])) {
3137
$vhost = get_virtual_host($_SERVER['VIRTUAL_HOST']);
3238

@@ -54,7 +60,13 @@ function wp_find_page_url() {
5460
}
5561
}
5662

57-
@define('DB_NAME', $_SERVER['WORDPRESS_DB_NAME']);
58-
@define('DB_USER', $_SERVER['WORDPRESS_DB_USER']);
63+
// integration with RiotKit Harbor
64+
if (isset($_SERVER['HTTP_HARBOR_REAL_IP']) && $_SERVER['HTTP_HARBOR_REAL_IP']) {
65+
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_HARBOR_REAL_IP'];
66+
}
67+
68+
// will always react on environment change
69+
@define('DB_NAME', $_SERVER['WORDPRESS_DB_NAME']);
70+
@define('DB_USER', $_SERVER['WORDPRESS_DB_USER']);
5971
@define('DB_PASSWORD', $_SERVER['WORDPRESS_DB_PASSWORD']);
60-
@define('DB_HOST', $_SERVER['WORDPRESS_DB_HOST']);
72+
@define('DB_HOST', $_SERVER['WORDPRESS_DB_HOST']);

0 commit comments

Comments
 (0)