-
Notifications
You must be signed in to change notification settings - Fork 6
/
fix-https-reverse-proxy.diff
84 lines (81 loc) · 3.73 KB
/
fix-https-reverse-proxy.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
diff --git a/index.php b/index.php
index 8d1b211..1c707b6 100755
--- a/index.php
+++ b/index.php
@@ -1,35 +1,52 @@
<?php
- $path = rtrim(str_replace('\\','/',dirname($_SERVER['PHP_SELF'])), '/');
- $url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $path;
- header('X-Frame-Options: DENY');
+function isHttps()
+{
+ if (array_key_exists("HTTPS", $_SERVER) && 'on' === $_SERVER["HTTPS"]) {
+ return true;
+ }
+ if (array_key_exists("SERVER_PORT", $_SERVER) && 443 === (int)$_SERVER["SERVER_PORT"]) {
+ return true;
+ }
+ if (array_key_exists("HTTP_X_FORWARDED_SSL", $_SERVER) && 'on' === $_SERVER["HTTP_X_FORWARDED_SSL"]) {
+ return true;
+ }
+ if (array_key_exists("HTTP_X_FORWARDED_PROTO", $_SERVER) && 'https' === $_SERVER["HTTP_X_FORWARDED_PROTO"]) {
+ return true;
+ }
+ return false;
+}
+$path = rtrim(str_replace('\\','/',dirname($_SERVER['PHP_SELF'])), '/');
+$url_host = getenv("HOST", false) !== false ? getenv("HOST", false) : $_SERVER['HTTP_HOST'];
+$url = ( isHttps() ? 'https://' : 'http://' ) . $url_host . $path;
+header('X-Frame-Options: DENY');
?>
<!doctype html>
<html class="no-js" lang="">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="description" content="">
- <meta name="viewport" content="width=device-width">
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="description" content="">
+ <meta name="viewport" content="width=device-width">
- <title>OpenSupports</title>
+ <title>OpenSupports</title>
- <link rel="icon" type="image/x-icon" href="<?=$url ?>/images/icon.png">
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/v4-shims.css">
- </head>
- <body>
- <div id="app"></div>
+ <link rel="icon" type="image/x-icon" href="<?=$url ?>/images/icon.png">
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/v4-shims.css">
+</head>
+<body>
+<div id="app"></div>
- <script>
- opensupports_version = '4.11.0';
- root = "<?=$url ?>";
- apiRoot = '<?=$url ?>/api';
- globalIndexPath = "<?=$path ?>";
- showLogs = false;
- </script>
- <?php if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)): ?>
- <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=String.prototype.startsWith,Array.from,Array.prototype.fill,Array.prototype.keys,Array.prototype.find,Array.prototype.findIndex,Array.prototype.includes,String.prototype.repeat,Number.isInteger,Promise&flags=gated"></script>
- <?php endif; ?>
- <script src="<?=$url ?>/bundle.js"></script>
- </body>
+<script>
+ opensupports_version = '4.11.0';
+ root = "<?=$url ?>";
+ apiRoot = '<?=$url ?>/api';
+ globalIndexPath = "<?=$path ?>";
+ showLogs = false;
+</script>
+<?php if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)): ?>
+ <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=String.prototype.startsWith,Array.from,Array.prototype.fill,Array.prototype.keys,Array.prototype.find,Array.prototype.findIndex,Array.prototype.includes,String.prototype.repeat,Number.isInteger,Promise&flags=gated"></script>
+<?php endif; ?>
+<script src="<?=$url ?>/bundle.js"></script>
+</body>
</html>