Skip to content

Commit 05c8f99

Browse files
committed
feat: add reverse proxy config
If people are smart and using reverse proxies, this commit should make life a little easier on them. Just set the "socketUrl" and/or "blipUrl" inside the "revsersProxy" setting and watch as your secure site becomes all green.
1 parent b353872 commit 05c8f99

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

index.php

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
if(array_key_exists("liveMapName", $srv)){
6363
$config->liveMapName = $srv["liveMapName"];
6464
}
65+
if(array_key_exists("reverseProxy", $srv)){
66+
$config->reverseProxy = $srv["reverseProxy"];
67+
}
6568

6669
$config->currentServer = $name;
6770

utils/config.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ class Config{
3636
"ip" => "127.0.0.1", // The IP (if on something different to the one in the config)
3737
"fivemPort" => "30120", // The fivem port
3838
"socketPort" => "30121", // Set to the port that you set in the "socket_port" convar (if different to the one in the config)
39-
"liveMapName" => "live_map" // Set to the resource's name (if different to the one in the config)
39+
"liveMapName" => "live_map", // Set to the resource's name (if different to the one in the config)
40+
41+
"reverseProxy" => array(
42+
"socketUrl" => "wss://some.server", // If we have a revers proxy server over at some.server that connects to the insecure fivemserver
43+
"blipUrl" => "https://some.server/some_blips.json"
44+
)
45+
4046
)
4147
);
4248
// These values will only be used if, the array doesn't contain it's values.
@@ -53,6 +59,9 @@ class Config{
5359
// Note: If you change the folder name on the GTA server you NEED to change this
5460
public $liveMapName = "live_map";
5561

62+
// If you run a reverse proxy, this will be a little easier for you to point it to it.
63+
public $reverseProxy = array();
64+
5665
// These will be injected into the JS code to configure how the map works
5766

5867
// The directory that contains the folders for the map tiles. Can be relative or, full URL..
@@ -102,7 +111,7 @@ public function gtaServer(){
102111
* @return string The URL used to connect to the websocket server (e.g. "ws://127.0.0.1:30121")
103112
*/
104113
public function socketUrl(){
105-
return "ws://$this->fivemIP:$this->socketPort/";
114+
return array_key_exists("socketUrl", $this->reverseProxy) ? $this->reverseProxy["socketUrl"] : "ws://$this->fivemIP:$this->socketPort/";
106115
}
107116

108117
/**
@@ -111,7 +120,7 @@ public function socketUrl(){
111120
* @return string The URL you can use to get the blips file (e.g. "http://127.0.0.1:30120/live_map/blips.json")
112121
*/
113122
public function blipUrl(){
114-
return $this->gtaServer() . $this->liveMapName . "/blips.json";
123+
return array_key_exists("blipUrl", $this->reverseProxy) ? $this->reverseProxy["blipUrl"] : $this->gtaServer() . $this->liveMapName . "/blips.json";
115124
}
116125

117126
private static $instance = NULL;

0 commit comments

Comments
 (0)