Eliminating port number in the url - java

I have a application developing in Java, Strut2 and Tomcat
and is been deployed n Tomcat 6.0
the URL to access is
http://websiste:8181/webAppName/some.action
Now I am trying to change the above url to
http://website/webAppName/some.action
can you please let me know how to eliminate Port number in URL

You should run the server on port 80 which is default for http.

You need Tomcat to use port 80 instead of 8181. Port 80 is the default port used when no port is specified. See this post for details on how to change the port number.
Edit:
Since you have Apache running on port 80, you can't serve your app from Tomcat on port 80 too. One option is to use Apache's mod_proxy (can be dangerous), or the Tomcat's Apache connector to get Apache to serve /webAppName/* from Tomcat instead of from your other website's resources.

If you can change the tomcat configuration, it's a simple matter to change it to port 80. More info is available here: http://www.klawitter.de/tomcat80.html

There are two ways to eliminate it :
1) Preferred way : set the server to listen at port 80 instead of 8181 as others have already mentioned
2) Non preferred way : Change Proxy settings in your browser to hit 8181 port instead of 80 for http protocol. This will force you to explicitly use 80 port when trying to reach other web sites.

Related

Glassfish cannot start, port is occupied

I tried to run my war application on port 80 instead of 8080. However when I change port number of Glassfish to 80 it cannot start because apache uses that port. My website is working on that port and I want to run my application in a subdomain of my website. What should I do to get rid of 8080 port in URL?
Two applications cannot share a TCP port on different subdomains since the concept of a subdomain/domain is specific to DNS and HTTP, not TCP itself. However, you can either keep both Apache and Glassfish on alternate ports (perhaps listening on 127.0.0.1 only) and use nginx or another reverse proxy. Alternatively, you can keep Apache on port 80 and instruct it to reverse-proxy requests on the subdomain to Glassfish, or the other way around.
You can host your website on Glassfish. It has a built-in http server.
Right click on server.
Click on add server.
Add glassfish server information. Click on choose. Then click on next.
After that, the created server is available under the server tab. Right click on the created server and start the server, then, create new web application.

Jetty list on port 80 for application which would usually be on another port

I think my issue may be not knowing exactly what to look for (or the terminology), so hopefully this will serve to also help future people with similar questions.
I have a webapp running on Jetty, deployed using a .war in the webapps dir, lets say it is:
mydomain.com/foo
So the .war file is named "foo.war".
I also have some server which listens on another port, say port 9000. I would like to make this accessible through port 80, but Jetty is using that port. It is a HTTP server, but the port it listens on is 9000 (And I cannot change this).
Is it possible to have mydomain.com/baz relay data to and from localhost:9000 and then back to the client on port 80?
Of course, this needs to be done through port 80 as to the outside world port 80 is the only one available, and jetty is already listening on port 80.
I suppose this would look like:
Client -> mydomain.com:80/baz -> mydomain.com:9000 -> mydomain.com:80/baz -> Client
Almost like an "iframe", only of course an iFrame would require the client to request mydomain.com:9000 which isn't open to the outside world.
You might find it straightforward to set up an Apache httpd which uses http proxying to provide a single set of URLs on port 80 to "clients", but which actually makes http requests to back end servers on non-standard ports behind the scenes.
Nginx can probably do this too.
Start here - http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

How to eliminate port number of tomcat server

I have a dedicated server and I have tomcat installed on it. But the only way to access tomcat is to give the port number in the URL.
For Example: http://server.mydomain.com:8080
takes me to the tomcat server.
How can I remove the port number from the URL????
As long as I was using it, this was fine but now I have generated a SOAP service and I have deployed it on axis2. Now the URL to access my service is like http://server.mydomain.com:8080/axis2/services/MyService?wsdl
which shows the port number, so how can I remove this port number??
OR is there any other way to make my service accessible without showing the port number??
Thanks
3 words: Apache Reverse Proxy
I hate dealing with Java/Tomcat idiosyncrasies like this so what I do is I reverse proxy through Apache to give Tomcat a nice/normal port 80 URL. I have a detailed answer on my approach here on Server Fault.
That way my Tomcat setup is sane & clean & Apache allows me more flexibility in front-end accessibility & control.
Not showing the port number means that it must run on port 80 (http) or 443 (https). For that you need to modify your tomcat configuration. I found this on the internet and hope it helps: http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port/

Apache, Tomcat and mod proxy http set up

I am running a web application on Tomcat (port 8080) with Apache (port 80) in front (on Ubuntu) using mod-proxy_http as the connector. The app is available through port 80 but also through port 8080. This is actually quite useful (when deploying/testing).
Are there are any particular disadvantages/vulnerabilities with keeping port 8080 open in this way?
My opinion is that you should close 8080 port, or at least allow it for certain host/IP. Less open ports, less problems. Opening port 8080 could let attacker to have more entry points (80 and 8080, using different technologies) and exploit different techniques. Also HTTPd server has much better security modules.
Have you consider using mod_ajp_proxy?
Hope this helps.

deploy java ee application to another port than 8080

Just wonder if i can deploy my java ee application in any application server for eg: glassfish, and user are able to access without typing the port number, for eg:http://abc.com
(my current application url will be http://abc.com:8080)
as from my knowledge, i might need another web server like for eg:Apache to redirect request to application server using mod_proxy module in order for me to achieve that, right?
kindly advise...
Setting up Apache to proxy requests from port 80 to your app/web server running on port 8080 is one way to eliminate the need for port numbers in your URLs. But it's certainly not the only way. You should be able to configure any J2EE application server or web server to run on port 80 instead of 8080 (a common default in J2EE app/web servers). The details of the configuration editing are app/web server specific. You may need root privileges on your system to bind to port 80.
You need to tell it to bind to port 80 instead of 8080, which is usually well documented how to since this is a common operation.
Note: Under Unix systems you need to be root to bind to port 80 - here an Apache frontend might be useful.

Categories