I am working on some project for that using spring 3.2.0. Whenever I run project it looks like
http://IpAddressWithPortNo.com/myprojectName.com/
IpAddressWithPortNo = localhost : 8080
I want to hide localhost:8080 or ip address.
Is there any method available to map this ip to my project?
http://myprojectName.com
I am using apache tomcat 7.0 and fedora 17.
The solution doesn't involve configuring Spring, but the hosts file of your operating system. On Ubuntu, it is found at /etc/hosts, I'm not sure if its the same for Fedora, but it should be.
You just need to add a line in the hosts file that looks like the following:
127.0.0.1 myprojectName.com
That's it. You then access the myprojectName.com address in your browser and it will look at your localhost, behind the scenes.
The above solution works if you only need name resolution for your local machine.
If you'd like to expand to your local or external network, the answer is less trivial:
for your local network, you need to register a custom domain on your network DNS server (see this and this for more information); if you have a network administrator, direct this requirement to him, explaining that you want to expose your local ip through a custom domain name
if you want to expose this name to the entire internet, you have to register the custom domain to a DNS registration service (you can find free DNS services as well, unfortunately I haven't used any lately and dyndns.org doesn't provide free dns service anymore, try searching free dns service on google and lookup some reviews)
The :8080 will go if you configure Tomcat to respond on port 80, or https on port 443.
You can use any host name that resolves to your network address. For instance if your machine name on the local network is athena.mycompany.com then http://athena.mycompany.com/myProjectName should work fine - but only within the local network.
To get to http://myprojectName.com you will need to configure a firewall/router to forward an incoming request (presumably from the Internet) to your machine. Internal access will likely not resolve this URL.
Gabriel has just posted an answer that should work from your machine, but other machines within your intranet would also require entries to map that name to your machine.
For doing exactly what you want, you need to configure apache tomcat to listen on port 80 and tell your operating system that myproject.com resolves to localhost.
To resolve myproject.com to localhost, add the following to your /etc/hosts file:
127.0.0.1 myproject.com
To change the port number to 80, open /usr/share/tomcat7/confserver.xml or /etc/tomcat7/server.xml (whichever applies to your system) and change Connector port = 8080 to Connector port = 80.
Related
When I use a Spring Boot app in local it uses, localhost:8080. When it is pushed to Pivotal Cloud Foundry, it has some route https://my-app.xyz-domain.com and we can access the URL without a port, what is happening behind the scene?
Please help me understand.
There is a default port number for each protocol which is used by the browser if none is specified. For https it is 443, for http 80 and for telnet 23.
On Unix and similar systems like Linux, those are often not available to a developer so other ports are used but then they have to be specified. 8080 is often available and looks like 80.
On CloudFoundry, your application is actually still running on localhost:8080. The reason that you can access your application through https://my-app.xyz-domain.com is that the platform handles routing the traffic from that URL to your application.
The way this works is as follows:
You deploy your application. It's run by the foundation in a container. The container is assigned a port, which it provides to the application through the $PORT env variable (this can technically change, but it's been 8080 for a long time). Your application then listens on localhost:$PORT or effectively localhost:8080.
The platform also runs Envoy in your container. It's configured to listen for incoming HTTP and HTTPS requests, and it will proxy that traffic to your application on localhost:$PORT.
Using the cf cli, you map a route to your application. This is a logical rule that tells the platform what external traffic should go to your application. A route can consist of a hostname, domain, and/or path. For example, my-cool-app.example.com or my-cool-app.example.com/foo. For a route to work, the domain must have its DNS directed to the platform.
When an end-user accesses the route that you mapped, the DNS resolves to the platform and the traffic is directed to the external load balancers (sometimes TCP/layer4, sometimes HTTPS/layer7) that sit in front of the platform. These proxies do not have knowledge of CF, they just proxy incoming traffic.
Traffic from the external load balancers is spread across the set of the platform Gorouters. The Gorouter is a second layer of proxies, but these proxies have knowledge of the platform, specifically, all of the routes that have been mapped on the platform and where those applications actually live.
When a request comes to Gorouter, it will recognize the route like my-cool-app.example.com and look up the location of the container where that app is running. Traffic from Gorouter is then proxied to the Envoy which is running in the app container. This ties into step two as the Envoy will route that traffic to your application.
All in total, incoming requests are routed like this:
Client/Browser -> External LBs -> Gorouters -> Envoy -> Application
First, you should change the port to 80 or 443, because HTTP corresponds to 80, and HTTPS corresponds to 443. Then, you should set the domain name to resolve to the current host, so that you can access the current application through the domain name. In addition, if you want to set the local domain name, then The hosts file should be modified.
I have started doing work with spring/hibernate to make webapps with java. I have made a basic app which is running on my localhost:8080 and I was wondering if there was an easy way to make it visible to someone else so they can see and use the webpage from their machine.
If They are on same network (ie a Home Network or Corporate Network) you just need to send them you ip and port (ie http://192.168.0.150:8080).
If you want to open your computer by the internet you need to setup you modem to open you 8080 port and need to discover you public IP ou contract a DDNS, like no-ip.
Maybe you can need to change some firewall configurations
If you don't want to configure firewall, port forward. you can try some dynamic dns service like www.no-ip.com, dyn, duck dns, freedns etc.
they will create a public url which will forward.
however at application level you may still need to configure the access permission like white list ip or address to listen
Can't access Tomcat using IP address
I have a few applications hosted on Tomcat running a machine called test-websites throuhg port 8080. So they are accessible like this:
http://test-websites:8080/app1/
http://test-websites:8080/app2/
...
http://test-websites:8080/appN/
What I need to do is make these applications accessible on my local network by:
http://app1.test-websites/
http://app2.test-websites/
...
http://appN.test-websites/
As I add new applications to Tomcat's webapps folder, I want them to be automatically available using the same subdomain pattern.
So I thought using Apache in front of Tomcat to make the URL rewriting would be a good idea, but so far I have not been able to configure the virtual host on Apache to make this redirect. I installed apache2 on port 80 and I see the default "It Works!" apache page when I access http://test-websites/, but I couldn't find how to make the redirects to the apps in the Tomcat following the format above.
I have searched for over 4 hours and didn't get an answer for this use case.. any help us much appreciated!
Thank you!
Eduardo
First you need to add a DNS entry for app1.test-websites, app2.test-websites,.. such that it points to test-websites. Generally CNAME entry works best in this case. If you only need the URLs to resolve on your local machine (for testing purpose), you can just update your /etc/hosts or C:\windows\system32\drivers\etc\hosts file. Otherwise you need to figure out how your company's network is setup and change the DNS entry (if it's a Windows domain network, normally there's a DNS service on the domain controller. On some smaller network you have to configure it on the router).
Next, the quickest way to achieve this is to not use apache2 to front it, bust simply have tomcat listening on port 80. You can setup virtual host on tomcat such that it serves different web-app depending on the URL requested.
I have Glassfish with an EAR deployed that includes a swing application that I run through Java Web Start which connects to my EJB through the #remote interface.
We have a server set up with a static IP and all I need to do is set /etc/hostname to my hostname (x.x.com) and in my /etc/hosts I have:
127.0.0.1 localhost
x.x.x.x x.x.com
Pretty simple. The application runs fine.
However, we want to migrate to EC2. I have a server up with Glassfish and everything is great. I have an Elastic IP pointed to it and my domain name pointed to that. All good.
The program downloads and updates fine also through Java Web Start.
The problem comes when trying to connect from my swing app to the server. It connects through CORBA, which I don't know much about.
I can't set the /etc/hosts file because the Elastic IP isn't the IP Address. Amazon assigns local addresses to the servers. I can't set /etc/hosts to one of those because if they were restarted it would change. And I don't want to edit it every time.
Does anyone know how to bypass this or fix it so Glassfish doesn't need it? It is killing me.
You should still be able to add an entry to your hosts file for your eIP - have you tried that?
EC2 instances all have a public IP and a private 10.X.X.X address. The eIP replaces the public IP address and is fixed (until you disassociate it).
The alternative with AWS, which will allow you to have a fixed private IP too, is to deploy to a VPC. Amazon have some very good documentation on VPCs.
What you're getting, in a nutshell, is comparable to a local network, so you can just pick your CIDR block and create subnets, for example 10.0.1.0/24. Now, when you launch an EC2 instance, you can launch into that VPC subnet and choose the private IP. Along with your eIP, you now have both IP addresses (public and private) set permanently, unless you decide to change them yourself (for whatever reason).
You can even add secondary IP addresses if you want.
I just deployed an instance of OpenMary TTS server on my Windows 2012 Azure VM and configured ttp endpoints for both port 80 and the default 59125 ports. I've tried launching mary server using both ports and I can't access it externally using either the DNS name or the external IP. I installed IIS on the same host and I am able to access the default page remotely so I know it is not an Azure configuration issue, rather something in OpenMary causing it to only accept requests coming from the loopback IP or localhost.
Is there a hostname setting I can supply on the cmd line via java property? I can change its port name via -Dsocket.port= setting but how do I tweak the host name it listens on? Does it make sense to set the server up behind IIS?
in the Windows Azure Portal, you need to configure the end point mapping.