deploy java ee application to another port than 8080 - java

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.

Related

How to use Docker to run various web servers on default ports on one server?

My goal is to have web servers that work on the default port so users don't have to type in a port #. Easy to do with LAMP stack, where A is apache... and no other web server exists. However, if I purchase general purpose hosting with Centos and I want to run
1) Gunicorn/NGINX for Python/Django -> access from example.com from outside (no port required to be entered by the web browser.
2) Spring framework in a Java EE container - Java EE defaults to port 8080 and other ports in that range but people just enter a domain name and expect it to work. -> So reachable from example2.com
3) Node.js - Reachable from example3.com
4) PHP apps such as WordPress, Drupal on LAMP - example3.com
Recommendations are appreciated.
My closest experience that seems to do this for example would be AWS with load balancer allowing access from public web - app servers accessible from only load balancer.
Thanks,
Bruce
You can use nearly any http server in front to do this kind of job.
bind everything (tomcat, nodejs, gunicorn, uwsgi, etc. pp.) to local http or file sockets and use the proxy feature of your favorite server to bundle them all on this host. With the naming of nginx: use different locations on one server and/or different server blocks with proper server names set to build your custom host.
A few servers:
nginx with proxy feature
apache2 supports setups like that, too if you use mod_proxy.
haproxy is another alternative
Finally it depends on your specific needs (and experiences) which setup to pick.
Edit: missed docker a little - but the same thing works for containers - except that you do not use file sockets, but make everything with (http) sockets in private or public nets.

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.

Running Tomcat service on same port as IIS Service

I'm trying to set up three services to run on the same port (port 80). Two of the services are hosted on IIS thus enabling bindings to use the same port. One of the three services is however hosted on a Tomcat server as it is a Java Servlet. How can i set this up so that all can be accessed through port 80?
I've tried using URL Rewrite in the IIS to forward the request to port 8080 where the Tomcat service is active but it doesn't work with other services being active on port 80.
Any other ideas?
EDIT
I have no support for URL Rewrite not working for this purpose other than my own attempts. If anyone have used it and knows it should work, please shout out as it would be an optimal solution with minimal complexity to the system!

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/

JBoss Binding IP addresses

I need some help from someone who understands JBoss Hostname Binding. I think the solution is easy, although it's complicated to explain.
I am deploying an application using JBoss (v4.2) and am having troubles configuring the application.
This application has two parts, a web site on port 8080 and web services on port 8080 using SOAP APIs.
My server sits behind a firewall, and has an alias, let's say it's called orange.mycompany.com
My problem is that I cannot get the console to connect to the web services. The website works, but I see an connection refused error connecting to the web services.
[xfire.transport.http.HttpChannel]
java.net.ConnectException: Connection
refused
There are 2 things I can control, the bind IP on Tomcat, and the URL of the web services.
If I start JBoss, and bind to the local IP address:
./run.sh -b 10.1.2.3
And I set the URL of the web services to be that same IP
url=http://10.1.2.3:8080/services
I can see the website on port 8080 from outside the firewall, but the console cannot connect to webservices.
From the server, orange, itself I cannot see the website by calling http://localhost:8080/ or http://10.1.2.3:8080 or orange.mycompany.com:8080
However, if I start JBoss and bind to 127.0.0.1:
./run.sh -b 127.0.0.1
And I set the URL of the web services to localhost
url=http://localhost:8080/services
Now I can't see the website at all from outside the firewall.
But from the server itself, I can see the website browsing http://localhost:8080 and the I can successfully connect to the web services. That's great, but I need the website to be accessible from outside.
Can anyone suggest any combination of settings that will let me browse the website and also let the console call webservices on localhost?
Never mind.
Start JBoss binding to all IP's works.
./run.sh -b 0.0.0.0
Aren't your running JIRA standalone, right?
I always run tomcat and jboss behind a apache with mod_jk. This still hide ports, what sounds great for newbies users.
Your server is behind a NAT?
Sometimes I use ProxyPass or RewriteRules (mod_rewrite) to provide external access, thru reverse proxy.

Categories