How to avoid connection loopbacks with DynDNS when I debug locally? - java

I'm developing with Java GAE and Google API's with OAuth authentication that requires an URL Callback that receives the access tokens.
To test locally, running Jetty in 127.0.0.1:8888/home.html?gwt.codesvr=127.0.0.1:9997, I've configure a DynDNS domain and set my router to redirect traffic from port 8888 to my machine.
When I do that DynDNS domain shows my router web configuration page, like I was browsing to my router local IP.
I've achieved a workaround activating my StrongVPN account to trick the router loopback, but when DynDNS refresh the VPN IP I can't access anymore, well I have to wait a lot of time to do the trick again.
How can I avoid these loopback connections? Should I set up a proxy? Anyone has met this scenario (local debug GAE+G.APIs+OAuth)?
Edit:
I'll show you my LAN configuration (trying to discard causes):
INTERNET (WAN IP) <-> ISP Router (192.168.1.1) <-> (192.168.1.2) Neutral Router (192.168.0.1) <-> (192.168.0.XX manual static IP) MacBook Local Server
I set this port forwarding configuration in my ISP Router to redirect the incoming port 80 connections to my 8888 port
- TCP port 80 to 192.168.1.2 port 8888
I set this port forwarding configuration in my Neutral Router
- Port 8888 to 192.168.0.XX
The configuration described would be OK because if I access through my mobile 3G connection to mydyndns.dyndns.org I access to Eclipse local web server.
Then, I tried to edit host file as Owen "point your DynDNS domain to 127.0.0.1" says but without success :(
If I set '127.0.0.1 mydyndns.dyndns.org' in my hosts file dyndns domain doesn't work, I think is because port forwarding, but I receive a not found, as if I type 127.0.0.1 in the browser. Eclipse server is attaching 127.0.0.1:8888 then port 80 doesn't have nothing to show.
If I set '127.0.0.1:8888 mydyndns.dyndns.org' in my hosts file I access to the ISP Router web configuration page as I was typing 192.168.1.1. But the address is inmediately replaced on the browser address bar for MY_WAN_IP:80
Then I think that a connection loopback is happening. Any idea about how to fix that :(?

You could edit the hosts file on your machine to point your DynDNS domain to 127.0.0.1 That's what I do.
The location of the hosts file depends on your operating system. Check the Wikipedia article to find it's location in your OS and how to edit it.
In addition to editing your hosts file, I think you can follow the advice in this question/answer to locally forward. https://serverfault.com/questions/102416/iptables-equivalent-for-mac-os-x

I change my ADSL Provider and the main router, with that I reconfigure the scenario as the documents says and it works.
I'm sorry for so specific question, that was a ISP problem who, for any reason, don't support or has any undocumented custom configuration to configure your own server.
Thanks

I fixed this problem by connecting to my ADSL Router via Telnet (the command after you're in telnet is "o router-web-configuration-ip-here") and then I issued the commands to check NAT loopback ("ip nat l"), after verifying it was off I issued the command to turn it on ("ip nat l on"). You can also edit the autoexec.net ("sys edit autoexec.net", "n" [twice], "ip nat l on", "x" ) of the router to make the change permanent.
I also did edit the HOSTS in my machine, placing my server's own local IP tied to the DynDNS host.
I'm using Windows 7 for development, I don't know about your specific configuration, but this might help others doing SO/HO dev.

Related

How can I make my SpringBoot app accessible with my public IP address?

I have a Java SpringBoot app running fine on localhost and it is accessible from any device connected to the same WI-FI. However, if I set server.address to my public IP address in application.properties and try to start my server, I get an error saying my 8080 port is in use.
What could be the problem?
I am using Windows 10.
Thank you!
To make your app accessible you don't need set server.address. Maybe if you use home router, you must try configure port forwarding for 8080 on router
Firstly, you need to make sure you do all of the below:
start your spring boot run on your local IP - if you are using windows open your cmd and type the following: IP config and check your ip
server: port: 8082 address: 10.0.0.x
(or 192.x.x.x) something like this
Make sure your firewalls are disabled for incoming requests. If you are using windows again go to firewall management and disable.
Go to your ISP management (router management) usually when you type your local IP in address bar of browser it will take to your router login from there find an option which says port forwarding and forward it to your port (in this case - 8082) and select your machine as the destination for all incoming requests to that port.
Finally just login from an external machine other than your network to test it out do the following: To find your public IP(just google whatsmyIP)
a.Test some get endpoint (publicip:8082/users) something like this

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).

JVisualVM remote working when destination is behind NAT?

I am in developer network and the JBoss to be monitored using JVisualVM is behind client firewall in separate network. JBoss is exposed to us through a NAT. The exposed JMX port works when using telnet from our developer network, but JVisualVM still doesn't find the remote JMX. Apparently this can be due to two things: 1) one or several dynamic RMI sockets need to be accessed, or 2) the "java.rmi.server.hostname" is not defined. My problem may be both points 1 and 2, but apparently since we have SSH access this can be tackled according to this site:
http://rafaelsteil.com/setting-up-jmx-for-jconsole-visualvm-on-ec2-plus-jetty-configuration/
“java.rmi.server.hostname” is the public hostname (like example.com) of your server, without HTTP or anything else. You cannot use an internal address, otherwise you won’t be able to remotely access the service.
However I have one question about the "java.rmi.server.hostname", should the defined IP address be the server internal IP or NAT IP which is publicly expoed to our developer network?
I have actually just tackled this problem myself and figured it out.
I would wager that the problem is the RMI connections - you can't predict which ports it will use and so you can't get it to work with a firewall.
The workaround is to use an SSH proxy:
SSH to the box where your application is running but use the -D option like this:
ssh user#remoteHost -D 9999
This will start a socks proxy on your local machine on port 9999.
Open JVisualVM and in the preferences, under 'network' configure it to use a socks proxy at localhost, on port 9999.
If you do the above, you should then be able to connect to the remote machine as normal and since all the RMI traffic is now going over the SSH proxy, it is punched through the firewall and works nicely.
Good luck :-)

Java TCP/IP Chat Room, how to make it work over internet

I have fully developed a chat room for multiple clients with multi-threaded server which does the job, however only on my local machine. I want to go beyond this, and make this chat room to be working over the internet. So far I have made the port forwarding on my router for TCP protocol to route to my local IP address, however this didn't solve the problem and I still can't connect the client, even on my own local network. What other steps should I follow to get my chat room working on my own local network and then the internet?
try disable (windows) firewall ?
So my friend the basic rule for make anything to work over internet is to do Port forwarding or in simple way you can say that to open your server for the public network. For that you need to make sure that the routing path is complete from internet machines to your desktop. For this to work you need to open the port for which you need to access your machine from firewall settings, and also ensuring that trafic is routed from your public IP address to the server's IP as your server will be private under some router or ISP.
Way to do that:
You need to configure your home network i.e router setting. So in your router, configure the port you want the communication to happen(say port 5443).
In your router, configure a port-forward for the port 5443 to the internal IP address of your actual server, also to port 5443.
Reference: https://www.noip.com/support/knowledgebase/general-port-forwarding-guide/
On your server(your Desktop Machine) ensure that your firewall settings for port 5443 is on and set to allow rather than block.

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