Feature Embedded proxy in your server.

Mkalo

ボーカロイド
Joined
Jun 1, 2011
Messages
1,118
Reaction score
888
Location
Japan
This was made in TFS 1.3 but should work in any TFS distribution as long you implement it correctly.

unknown[1].png

It works by changing the gameserver ip and port that the client is going to connect to. The proxyId is bound to the account and should be changed through your website. I won't provide any web page for this as there is too many AAC's so if you use it please consider sharing the page code with everyone (It would be nice since you are using this for free.)

You can add as many proxies you want in config.lua, tho it won't check if the proxy is alive or not.

Changes:
proxyList.patch · GitHub

And this in the database:
SQL:
ALTER TABLE `accounts` ADD `proxy_id` INT NOT NULL DEFAULT '0' AFTER `lastday`;
How to setup your proxy using nginx:

Run:
Code:
sudo nano /etc/nginx/nginx.conf
Add this:
Code:
stream {
    server {
        listen YOUR_PROXY_PORT;
        proxy_pass SERVER_IP:SERVER_PORT;
    }
}
Save it and run:
Code:
sudo nginx -s reload
 

Attachments

Last edited by a moderator:

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,466
Reaction score
1,162
Location
Norway, Oslo
Nice, gonna be tricky to parse this config.lua file, but I will give it a go with Znote AAC.
Lua:
proxyList = {
    [1] = {ip = "158.69.12.213", port = 7172, name = "USA"},
    [2] = {ip = "2.2.2.2", port = 7177, name = "Germany"},
    [3] = {ip = "3.3.3.3", port = 7178, name = "Germany X2"}
}
 
OP
Mkalo

Mkalo

ボーカロイド
Joined
Jun 1, 2011
Messages
1,118
Reaction score
888
Location
Japan
Change the value in config to make easier for AAC's to parse the proxy list now the format is a string with:

Code:
"ID,IP,PORT,NAME;ID,IP,PORT,NAME..."
Each proxyInfo contains 4 values and they are separated by ";".
 

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,258
Reaction score
379
Nice release @Mkalo

I was in the process of testing it but I ran into this problem on the nginx part:
Code:
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:87
 
OP
Mkalo

Mkalo

ボーカロイド
Joined
Jun 1, 2011
Messages
1,118
Reaction score
888
Location
Japan
Nice release @Mkalo

I was in the process of testing it but I ran into this problem on the nginx part:
Code:
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:87
Make sure you have nginx-full installed. The normal nginx doesnt comme with the stream directive enabled.
 

Macadao

Banned User
Joined
Dec 19, 2016
Messages
147
Reaction score
1
How to install on apache and all we need is here on this thread? very thanks
 

Lais Prad

Disgusting Scammer
Joined
Apr 12, 2017
Messages
153
Reaction score
14
This was made in TFS 1.3 but should work in any TFS distribution as long you implement it correctly.

View attachment 29645

It works by changing the gameserver ip and port that the client is going to connect to. The proxyId is bound to the account and should be changed through your website. I won't provide any web page for this as there is too many AAC's so if you use it please consider sharing the page code with everyone (It would be nice since you are using this for free.)

You can add as many proxies you want in config.lua, tho it won't check if the proxy is alive or not.

Changes:
proxyList.patch · GitHub

And this in the database:
SQL:
ALTER TABLE `accounts` ADD `proxy_id` INT NOT NULL DEFAULT '0' AFTER `lastday`;
How to setup your proxy using nginx:

Run:
Code:
sudo nano /etc/nginx/nginx.conf
Add this:
Code:
stream {
    server {
        listen YOUR_PROXY_PORT;
        proxy_pass SERVER_IP:SERVER_PORT;
    }
}
Save it and run:
Code:
sudo nginx -s reload
How to setup it on apache, I read some tutorials and I could not.

How To Use Apache HTTP Server As Reverse-Proxy Using mod_proxy Extension | DigitalOcean
Setting up a basic web proxy in apache
 

Lais Prad

Disgusting Scammer
Joined
Apr 12, 2017
Messages
153
Reaction score
14
Nice release @Mkalo

I was in the process of testing it but I ran into this problem on the nginx part:
Code:
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:87
Did you solved this? Same here and I was installed nginx-full
 

Pedrook

Excellent OT User
Joined
May 24, 2009
Messages
332
Reaction score
65
Do you need to have three different machines? 1 in each zone? 1 BR 1 USA 1 CANADA? idk
 

klenio0

Well-Known Member
Joined
May 10, 2010
Messages
80
Reaction score
0
What is the true function of this? would it be a tunel or just to mask the player's ip?
 

kor

PHP ziom
Premium User
Joined
Jul 12, 2008
Messages
91
Reaction score
57
Location
Bialystok, Poland
Hello @Mkalo

I have server in Europe, bought small VPS in US, installed there nginx, configured it to stream player packets to my gamesevrer port in EU with configuration you provided.

A.A.A.A - IP of EU server
B.B.B.B - IP of US proxy server
C.C.C.C - IP of Brazilian player
Code:
stream {
    server {
        listen 7172;
        proxy_pass A.A.A.A:7172;
    }
}
Here is example dump for one player from `tcptrack -r 5 -i eth0`
Code:
   Client             Server
C.C.C.C:49713     B.B.B.B:5061
B.B.B.B:56642     A.A.A.A:7172
And it works like a charm.

The problem is on EU server side all players have the same IP (B.B.B.B), so having a rule
Code:
iptables -A INPUT -p tcp --syn --dport 7172 -m connlimit --connlimit-above 3 -j REJECT
I will cut out every 3+ player using my US proxy.

I was trying to pass player headers to my EU server in nginx configuration, for example by
Code:
stream {
    server {
        listen 7172;
        proxy_pass_request_headers on;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Host $remote_addr;
        proxy_pass A.A.A.A:5061;
#        proxy_pass_request_headers on;
    }
}
But none of the lines (even one by one) don't cooperate with `stream`. How can I pass player's IP through stream to my server?
 

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,835
Reaction score
185
Hello @MkaloBut none of the lines (even one by one) don't cooperate with `stream`. How can I pass player's IP through stream to my server?
Have your tried with:
Code:
proxy_bind $remote_addr transparent;
?
 

kor

PHP ziom
Premium User
Joined
Jul 12, 2008
Messages
91
Reaction score
57
Location
Bialystok, Poland
Not yet, but I did now. My nginx version is 1.10.3 and it don't support `transparent` parameter (it's supported from 1.11). I was trying to make an upgrade following this tutorial How to Install Nginx Latest Version on Ubuntu 16.04 and Ubuntu 16.10 but for now I'm unable because an error "nginx : Depends: libssl1.0.0 (>= 1.0.2~beta3) but it is not installable". Sad, that latest nginx version at apt is only 1.10.3. I will try later to upgrade it and I will test again.

What version of nginx do you have? proxy_bind works for you with transparent parameter?
 

kor

PHP ziom
Premium User
Joined
Jul 12, 2008
Messages
91
Reaction score
57
Location
Bialystok, Poland
Not yet, but I did now. My nginx version is 1.10.3 and it don't support `transparent` parameter (it's supported from 1.11). I was trying to make an upgrade following this tutorial How to Install Nginx Latest Version on Ubuntu 16.04 and Ubuntu 16.10 but for now I'm unable because an error "nginx : Depends: libssl1.0.0 (>= 1.0.2~beta3) but it is not installable". Sad, that latest nginx version at apt is only 1.10.3. I will try later to upgrade it and I will test again.

What version of nginx do you have? proxy_bind works for you with transparent parameter?
Edit: My distro is Debian GNU/Linux 9 (stretch)
 

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,835
Reaction score
185
What version of nginx do you have? proxy_bind works for you with transparent parameter?
Sorry, I'm not using nginx proxy. Anyway, my server is also Debian and it's pretty old, thus nginx version available on it is 1.12.2.

I have following /etc/apt/sources.list:
Code:
# jessie-updates, previously known as 'volatile'
deb http://debian.mirrors.ovh.net/debian/ jessie-updates main
deb-src http://debian.mirrors.ovh.net/debian/ jessie-updates main

# jessie-backports, previously on backports.debian.org
deb http://debian.mirrors.ovh.net/debian/ jessie-backports main
deb-src http://debian.mirrors.ovh.net/debian/ jessie-backports main

deb http://debian.mirrors.ovh.net/debian/ jessie main contrib non-free
deb-src http://debian.mirrors.ovh.net/debian/ jessie main contrib non-free
deb [arch=amd64] https://download.docker.com/linux/debian jessie stable
 
Top