kito2
www.masteria.net
Seems really useful!
Facing a similar issue, have you made any progress regarding this?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 ruleI will cut out every 3+ player using my US proxy.Code:iptables -A INPUT -p tcp --syn --dport 7172 -m connlimit --connlimit-above 3 -j REJECT
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?
proxy_bind $remote_addr transparent;
ptables -A INPUT -p tcp --dport 7172 -s USA_IP -j ACCEPT
iptables -A INPUT -p tcp --syn --dport 7172 -m connlimit --connlimit-above 3 -j REJECT
The only problem I have is having players connect to the game server via the proxy while still being able to detect their real IP address on the game server. I also use a seperate login server on another machine, but that doesn't really matter, even if one didn't they would have the same issue.@sick7 My case is a little different. I'm using The Forgotten Login Server (Milice/forgottenloginserver) which is hosted on EU machine so I always have the real IP address of connecting player. Answering your question, I didn't made any progress with passing player IP, so still if player connect to my EU server through USA proxy, every of them has the IP of USA proxy ingame. Reffering to my problem with iptables rules I have modified them to
So if there is more than 3 connections from the same IP they will be rejected except those from USA proxy.PHP:ptables -A INPUT -p tcp --dport 7172 -s USA_IP -j ACCEPT iptables -A INPUT -p tcp --syn --dport 7172 -m connlimit --connlimit-above 3 -j REJECT
@GSMaster Not exactly, if you have prepared characters list correctly (entry with seleted character point to your BR IP), player will connect to your EU server through this proxy, not only during login but whole game.
When I add this proxy script, when I try to log in only to account and then not login, what can it be?it work in tfs 0.4 whitout modifications in the codes?
It's about tunneling into a better route (so users far away from the host can have lower latency and play smoothly) made inside the server.what the point of this?
i need nginx installed in the 2 machines?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
Have your tried with:
?Code:proxy_bind $remote_addr transparent;
In my case also all players have the same IP if any of them is connecting through proxy. That's why I asked Mkalo how to avoid that and here is his reply:
But sadly my version of nginx don't support "transparent" parameters
About ping improvement, you don't see difference because your proxy is in BR and players are from BR. In my case, I have proxy in USA, server in EU and players connecting from South America through proxy have even 80 ms better ping than directly connected to server in EU.
u login through server you will have proxy IP no ? make proxy log character name : IPI would like to help you, but I don't undersyand you![]()
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
Active: failed (Result: exit-code) since Wed 2019-02-20 11:25:21 EST; 9s ago
Process: 2584 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 2573 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 2670 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 2574 (code=exited, status=0/SUCCESS)
Feb 20 11:25:21 xxxxxxxxxxxxxxxxxxxxxxxxxx nginx[2670]: nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:16
Feb 20 11:25:21 xxxxxxxxxxxxxxxxxxxxxxxxxx nginx[2670]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 20 11:25:21 xxxxxxxxxxxxxxxxxxxxxxxxxx systemd[1]: nginx.service: control process exited, code=exited status=1
Feb 20 11:25:21 xxxxxxxxxxxxxxxxxxxxxxxxxx systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 20 11:25:21 xxxxxxxxxxxxxxxxxxxxxxxxxx systemd[1]: Unit nginx.service entered failed state.
[email protected]:~# service nginx restart