LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-20-2014, 12:01 AM   #1
PygamePi
LQ Newbie
 
Registered: Mar 2014
Posts: 5

Rep: Reputation: Disabled
Question Routing incoming port 80 traffic to new port


I am running Apache2 for my HTTP server. I also have an ssh server running and multiple Minecraft servers running. I've been trying to figure out how to make it so people connecting to my minecraft servers just have to use a url and not a url and a port.

Example: Using URL:Port www.example.com:25565
Usomg URL:Port www.example.com:25566
Using URL www.example.com/vanilla
Using URL www.example.com/Pixelmon

So how would I accomplish routing these certain URL's to different ports so people can connect just using a URL?

I have seen stuff that uses nginx to reverse proxy, but I was never able to get it to work.
 
Old 03-20-2014, 03:10 PM   #2
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 68

Rep: Reputation: 13
well , in your web server root folder ( or in virtual host .. depending ) make some folders named vanilla and Pixelmon ..
inside create index.php


edit index.php

Code:
?php

   header( 'Location: http://example.com:25565' ) ;

?>

any client clicking example.com/vanilla will be redirected towards domain':'port


same with Pixelmon but change port number

same trick can be used for domain/webmail , domain/games domain/anything redirecting to another ip or domain

make sure you change folder permissions recursively to 744 just to be safe !!! (all->owner ; read ->group ; read->world ) using
Code:
chmod  -R 744  folder_name
<!-- Knoledge is achieved in small steps -->

Last edited by yo8rxp; 03-20-2014 at 03:30 PM.
 
Old 03-20-2014, 05:53 PM   #3
PygamePi
LQ Newbie
 
Registered: Mar 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thumbs up Thanks yo8rxp

Thank you so much this is the easiest thing I have found or have been given so far and I've been trying to figure this out for months.
 
Old 03-20-2014, 07:24 PM   #4
PygamePi
LQ Newbie
 
Registered: Mar 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Question Minecraft connects through port 25565

So it did work for me and when I used the URL in a web browser it routed me to the URL+port, but since Minecraft tries to connect with port 25565 it didn't work for that. So I now have Apache listening on ports 80 and 25565, so when Minecraft tries to connect with port 25565 using the URL it would be redirected to a different port 25566.

This isn't working though. Am I going about this correctly or am I missing something? I have Apache listening on ports 80 and 25565, I have one server running on port 25566 and the other running on port 25567. I checked if I was routed correctly and I was, all the ports I am using are all open on my modem and computer. Should this work or should it not? I must be missing something.
 
Old 03-20-2014, 11:49 PM   #5
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 68

Rep: Reputation: 13
Wow , you lost me into the darkness !

25576 , 25566, 25565, 3 servers ,,, could ya clear me up ?

sometimes if you test port forwarding behind the router , it can hit you on the walls instead of local IP ...
for exmple my web is running on 192.168.4.100 and 192.168.4.1 ( router ) forwarding incoming 80 port to it. but from a a second PC say 192.168.4.22 if trying to hit 89.120.186.195 or domain name , it wont respond web server but router management itself...(had to build a local DNS server to fix this )
In simple words , some routers will port forward only external connections, not local ones .

test it using a mobile connection or ask a friend
there is a free tool : canyouseeme dot org where can test ports and / or open services

Best of all , try posting here a schematic or a diagram to understand better . try using less words as I am from Romania eastern Europe so i might be difficult understanting

i attached a picture here , tell me if it is correct
Attached Images
File Type: png minecraft.png (112.1 KB, 5 views)

Last edited by yo8rxp; 03-21-2014 at 12:13 AM.
 
Old 03-21-2014, 12:31 AM   #6
PygamePi
LQ Newbie
 
Registered: Mar 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Yes that looks correct, but I think the connection out from the Minecraft server needs to be 25565. Explanation below.

ok here are the ip and stuff.

External ip: 65.130.33.25

Computer ip: 192.168.0.12

The first Minecraft server is listening on port: 25566

The second Minecraft server is listening on port: 25567

Appache is listening on ports: 80 and 25565

When trying to connect to a Minecraft server Minecraft uses port 25565 by default. That is why Appache is listening to port 25565.
Appache would receive the traffic from Minecraft and the index.php (you told me about) would route it to one of the Minecraft servers ports.

When using the URL I want to forward to a different port in a web browser it works it tries to connect to the URL:Port. When trying to use the URL to connect to a Minecraft server Minecraft cannot establish a connection. This is the same for when I use some PHP code to get server info. the forwarding works, but the connection can not be established.

The "...." are to hold the whitespace.

................................................................|--URL--Index.php-->Minecraft--Server--Port:25566
................................................................|
Computer--Minecraft--Port:25565-->Server----|
................................................................|
................................................................|--URL--Index.php-->Minecraft--Server--Port:25567


Minecraft---Server---Port:25566--->Server-------->Port:25565----Minecraft----Computer

Minecraft---Server---Port:25567--->Server-------->Port:25565----Minecraft----Computer

Last edited by PygamePi; 03-21-2014 at 12:48 AM.
 
Old 03-21-2014, 01:30 AM   #7
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 68

Rep: Reputation: 13
yes , just because php redirect i ve told ya about , works only in php enabled browsers , minecraft probably (sure ) does not know how to interpret php in order to initiate a connection .

if having more than one public IP , the it would've been simple like port forwarding in 25565 out 25566 for one IP, and 25565 in 25567 for the second IP , but you only got one public IP available

have to rethink another solution ... it might take a while ! dig forward and put here what you got , and together will come up a sollution !
sincerely ,
Gabriel linux-romania dot com
 
Old 03-21-2014, 03:03 AM   #8
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 68

Rep: Reputation: 13
well ,from my point of view , you should have a main maincraft server on port 25565 default , and there using some plugins to present to the client different server connection like domain:25567 and domain:25567 that points toward different servers.
Or some tcp sniffer that traps vanila and pixelmon words on port25565 and reroute it in different servers , solution i cannot rely on.

Basicaly , like assault cube game main server , where all clients goes , and from there select broadcasted IP : port

Last edited by yo8rxp; 03-21-2014 at 03:08 AM.
 
Old 03-21-2014, 04:15 AM   #9
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 68

Rep: Reputation: 13
Just to be sure .... minecraft client side is standalone software or just playing live within brower ?
If it is within browser , it should.ve been working by now , if it is a standalone software, then surely not !
 
Old 03-24-2014, 06:31 PM   #10
PygamePi
LQ Newbie
 
Registered: Mar 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Minecraft is a game, so yes it is standalone.

I've seen stuff about use nginx as a reverse proxy to route traffic server side, but I never got that working. I've also seen stuff about Apache routing traffic, but I never got that working either.

I have not got it working to where I want it just using an ip, but I did get it working. The player has to specify the port, but it's better than waiting for another solution to run two servers. The query for my webpage is also working.

If your willing to help me out though I would love to still try and figure out if this is possible.
 
Old 03-25-2014, 04:39 AM   #11
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,287

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
This isn't really my kind of thing, but it reminds me of threads I've seen where the answer is mod-rewrite in Apache.
HTH
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing return traffic based on the NIC of the incoming traffic? adamk75 Linux - Networking 3 12-11-2011 04:27 AM
Routing traffic by port number to specific interface meekamoo Linux - Networking 3 01-17-2011 08:14 AM
Redirect incoming traffic to an other port (ubuntu openvpn server) krisox Linux - Newbie 3 12-06-2010 12:22 AM
port based routing for local traffic houska Linux - Networking 2 05-24-2009 07:10 AM


All times are GMT -5. The time now is 03:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration