'Port Forward' a url - java

I am using a hosting service to have my minecraft server run.
I was wondering if it was possible to "forward a port" to a url. ie:
change 25561 to 25565 so that the minecraft client reads the url and the users don't have to put in the port of the website.
A record: play.mydomain.tk 94.23.16.94
I want it so that when users put in the url on the minecraft client(which, if not defined, automatically selects port 25565) don't have to put in the custom port.
Not sure if there is a way to do this.
I am aware Apache can use VHosts to host on the same server with the same port, but there must be some way to do this with other servers.

What you need is a SRV record to forward the minecraft 'service' to the right port on your hosting server. I'm doing this with mc.jgsw.me (which forwards to port 25569) and it took me flipping ages to work out.

If, as stated above, some other piece of software is already using port 25565 on your IP address, then it will be impossible to use that port on your Minecraft server without using a different IP address.
You could set up some sort of gateway that redirects traffic to server.example.com:25565 through to your server at x.x.x.x:25561 and vice versa. This could be in the form of an SRV entry on a DNS server. You would need to own the domain to do this, but some domains can be very cheap. More info here from an SRV provider.

Related

Public to Local IP Communication

I have created project which has two components as Desktop client and web.
web server is communicating to the my another program which i run as client on other systems.
After connecting those clients communication is happening in network as all IP's within network are reachable.
However, when i deployed web app on public IP now i am not able to connect the clients as the local IP's of those clients are not reachable by server.
How can i achieve this communication between local IP to public and vice versa?
There are multiple ways to achieve this.
Anyways, if you want the service to be reachable publically then you´ll probalby want to forward the Port to the machine running the service.
Also, make sure the Firewall allows connections to this port.
Since you´re talking about Web-Apps it´s probably HTTP, Port 80 TCP, or HTTPS, the encrypted version of HTTP running on port 443 TCP.
To explain it, your ISP gives you one public IP address.
Since you probably have multiple devices using internet, they all appear in the internet as the one IP address your provider gave you.
Whenever you send something out your router will remember where you tried to connect and if a response comes in your router knows which device to send the response to.
Now, since you want someone to connect to you, there was no request so your router does not know where to put the packet and simply blocks it.
In most routers you can configure something usually called NAT or Port Forwarding. You simply specify that communication on Port 80 or 443 should be routed to the internal IP. It has one of the following formats:
192.168.0.1 - 192.168.255.254
172.16.XXX.XXX - 172.31.255.254
10.0.0.0 – 10.255.255.254

Change localhost to something like localhost.dev in dynamic web project

I am creating a dynamic web project in java. I want to deploy it in a application server. By default we have hostname as localhost:port/appname. I want to change it to localhost.com/myapp. How can i do that? Do i need to change something in my project or tomcat or hostfile. Please elaborate.
I fear there may be some confusion about how web servers work.
In your browser the URL http://localhost:8080/application_name will resolve internally to 127.0.0.1 (localhost) as this is a built in address. 127.0.0.1 is a loop back address pointing to the machine you're on. If you're hosting the server on the same machine as the you're trying to navigate to this is why the localhost address works.
If you were on another machine you would need to either directly input the IP address of the server or use a DNS record to point the IP address to a URL you own and control.
Browser are also programmed to default to port 80 for http and port 443 for https so if you don't want to have to provide a port have your server bind to port 80. This way you'll only need to navigate to http://localhost/application_name
When deploying the application to a server you want to be externally accessible you'll purchase a domain, register the DNS record and point it at servers external IP address (You may need to configure firewall and network rules).

Jersey - getting HOST IP and PORT programmatically

I have a jersey service up and running. On server start up, i want the ip address and the port on which this service is deployed. This has to be done programmatically. Any ideas ??
Thanks.
Regards,
Check this one:
How can I get a the host name (with port) that a servlet is at
Since Jersey is a Servlet implementation, it may be of help.
i want the ip address and the port on which this service is deployed
In fact the question is quite incorrect. Speaking about the IP addresses, your application may be deployed on some host with several network interfaces and therefore is available on several IPs. Which one is required for you then? Method getServerName returns the address, to which the request was made, as I remember.

How do I determine the hostname of a web server from an app server in Java/Apache

I'm running a Java application on Apache. I'm trying to find a way to allow my app server code to know the hostname of the web server. Is there a way to do this?
Running
InetAddress addr = InetAddress.getLocalHost();
String hostname = addr.getHostName();
or
(HttpServletResponse)response.getHeader("Host");
both predictably yield the app server's hostname.
Much depends on the configuration of your webservers, but I found that with Apache in front of JBoss, getRemoteHost returned the address of the Web Server.
Might be worth a go
I have handled this in a few ways:
Explicitly tell the app what host name it should be using via system properties
Have a rewrite rule in Apache that adds a header to the request, such as X-originally-For
Read the X-Forwarded-For header from the request
Note: I don't particularly like #3. Since the XFF header is passed host to host, you can't trust the addresses added by hosts outside your control.

How to host a Java EE website on GlassFish?

I have already deployed my web application on GlassFish at http://localhost:8080/Elibrary/.
So how can I configure my server to make "Elibrary" accessible from the Internet?
I know that in ASP we can use IIS to alias the from domain.
Could someone please let me know or point me to some documentation?
If you are hosting in your network, then you have to get IP of the machine which is running your app i.e. is your local ip inside ur network. To get your ip, run ifconfig on mac/unix/linux and ipconfig on windows.
Then go to your router settings. Generally every router has specific ip to access settings from browser like belkin has 'http://192.168.2.1'.
In your router settings you have to look for 'virtual servers', 'port forwarding' etc. The actual concept is port forwarding but different routers say it differently in the settings. These settings should be in firewall or security sections.
Once you found the settings, there you will have to tell the inbound port range and map it to the local ip (which we have above) and the outbound port range. It is saying that when ever a request comes on the router on the inbound port range then forward that request to local ip and port range. In your case, the port range will be to (for both inbound and outbound). Note that some routers dont have range for ports instead only have one port per entry, so you just have to put .
NOTE: To get the IP for settings of your router, try this site.
I hope this is what you looking for.
Nginx or Apache will work will in that scenario, processing virtual hosts and forwarding to an external application. Example for nginx.
Put this in place of the server section in an existing config file, unless using Debian/Ubuntu or other system where the server configurations are split into their own files.
server {
listen ip:80;
server_name virtualhostname.tld;
location "/" {
proxy_pass http://localhost:8080/;
};
};
Now http://virtualhostname.tld/Elibrary will work to access your application.
You can add rewiriting to get rid of Elibrary, and you find Apache equivalents of this online.

Categories

Resources