Jetty and apache same host - java

I have a vps from which I would like to serve a wordpress site, and a Tapestry5 webapp.
I usually use jetty for hosting my webapps, and apache for wordpress, but I am struggling to find a rough guide on how to configure both of these to play nicely together on the same host.
My aim is to have:
blog.foo.com -> The apache server hosting wordpress
foo.com -> The jetty webapp.
I want to avoid having port numbers showing in the address bar, so ideally I am thinking perhaps jetty or apache can check the URL, spot which one should respond, and forward the request appropriately. Since i'm new to this area, I'm struggling to find a guide (or rather.. know which guides to even look for) to achieve this.
My questions are:
Is this possible?
Roughly how does one go about setting this up - is there a specific part of either of the documentations which will help me? Which one of these should be listening on port 80 (assuming they can't both be on that port)?

Related

How would I implement an embedded SFTP Server on Openshift

Background Context:
Due to enterprise limitations, an uncooperative 3rd party vendor, and a lack of internal tools, this approach has been deemed most desirable. I am fully aware that there are easier ways to do this, but that decision is a couple of pay grades away from my hands, and I'm not about to fund new development efforts out of my own pocket.
Problem:
We need to send an internal file to an external vendor. The team responsible for these types of files only transfers with SFTP, while our vendor only accepts files via REST API calls. The idea we came up with (considering the above constraints) was to use our OpenShift environment to host a "middle-man" SFTP server (running from a jar file) that will hit the vendor's API after our team sends it the file.
I have learned that if we want to get SFTP to work with OpenShift we need to set up of our cluster and pods with an ingress/external IP. This looks promising, but due to enterprise bureaucracy, I'm waiting for the OpenShift admins to make the required changes before I can see if this works, and I'm running out of time.
Questions:
Is this approach even possible with the technologies involved? Am I on the right track?
Are there other configuration options I should be using instead of what I explained above?
Are there any clever ways in which an SFTP client can send a file via HTTP request? So instead of running an embedded SFTP server, we could just set up a web service instead (this is what our infrastructure supports and prefers).
References:
https://docs.openshift.com/container-platform/4.5/networking/configuring_ingress_cluster_traffic/configuring-externalip.html
https://docs.openshift.com/container-platform/4.5/networking/configuring_ingress_cluster_traffic/configuring-ingress-cluster-traffic-service-external-ip.html#configuring-ingress-cluster-traffic-service-external-ip
That's totally possible, I have done it in the past as well with OpenShift 3.10. The approach to use externalIPs is the right way.

How to make Java EE application go online without web hosting?

I am learning to make a web application, and have a Java EE web application that uses Apache tomcat as server and web container. Currently, I am able to run the application and the tomcat server (localhost:8080/chatsystemWar)
I am trying to make the application go online without using web hosting. Could someone please help me understand the following?
1-Is it possible?
2-To my surprise, all computers at my house are able to access the application by replacing the "localhost" part with the computer name. How come?
3-Because of 2, I guess I have a working server and application, so all I should need is to somehow get the Internet to know about the application. Would buying a domain name help? What needs to be done after buying one?
4-Would modifying server.xml help?
Thank you very much. This is my first question on stack overflow, but I have been relying on you guys for at least a year now. You guys are awesome!
Long story short, if you want to expose your web application to the wider internet, it must be hosted on an internet facing web server.
You could host it yourself, on your own machine, and open up port 80 on your router, and ask your ISP for a static IP address (or use a dynamic DNS service like NoIP), but that is not really ideal and exposes your machine to the internet for all and sundry to hack on.
A better choice is to purchase web hosting from a company that specializes in such things. Or you could spin up a web server on Amazon AWS and handle it yourself, but either way, you won't be opening up your home network to the internet.
This is a big topic and you'll have to do some more research to learn about all the different aspects.
Is it possible?
Yes.
To my surprise, all computers at my house are able to access the application by replacing the "localhost" part with the computer name. How come?
Because they are all on the same local network.
Because of 2, I guess I have a working server and application, so all I should need is to somehow get the Internet to know about the application. Would buying a domain name help? What needs to be done after buying one?
Yes, a domain name would help, but is not needed. What you need is a static IP address (uncommon for homes, usually cost extra) and to configure your router/firewall to allow the traffic to flow.
Way too broad a topic to cover here.
Would modifying server.xml help?
No.

Deploying Netbeans REST webservice on Apache server

I'm studying webservices in differents languages and now, I'm stuck on Netbeans one.
I easily create a "RESTful web service with Database" on localhost.
So, I use a MySQL (Connector/J driver) connection with GlassFish server.
My question is : what's the difference between an Apache server and a GlassFish one ?
Indeed, I aim to deploy this webservice on Apache server but I have no idea to do it.
Is someone have tips or ways to help me ?
Thanks a lot !
I'm assuming you followed this tutorial.
If you mean good old trusty Apache httpd, you won't be able to deploy the project you created to that server, what you create is a Java Enterprise application (and more specifically a WAR, a Webapplication ARchive), and you will need a server capable of deploying that type of applications - like of course Glassfish, but also Apache Tomcat, jetty or any of the Java Enterprise Edition servers
Still assuming that you're talking about Apache httpd, that one and Glassfish are entirely different beasts that serve different purposes, Glassfish is indeed capable of serving up content over http but it contains much more functionality than that, see the above Wikipedia link on Java EE for more links and pointers.
EDIT: you cannot run a servlet container like Tomcat or a Java EE server like GlassFish "inside" an Apache server like you would run php "inside" Apache with mod_php, but it's quite easy to run them alongside each other, where the Apache httpd server is the one that faces outward and basically forwards calls to the backend Java server. There are several techniques to achieve this result, the most popular is probably using mod_jk as explained here for Tomcat and here for Glassfish. Alternatively you could setup mod_proxy, a comparison of these two scenarios here on SO.
Anyways, it's not always necessary to front a Tomcat or Glassfish with an Apache but it may be needed e.g. if the website is serving hybrid content partially written in php or another apache-hosted scripting language or useful to avoid using the servlet container to serve up massive quantities of static content, often not their strongest point. For many applications it's perfectly OK to have a Tomcat or a Glassfish serve up all content avoiding the extra complications introduced by mod_proxy or mod_jk and the dual management of both servers.
open server.xml file in conf folder of apache tomcat. And check for line
Here you can see port =5051 means apache tomcat is configured in port 5051
Open we browser and type http://localhost:5051
Then click "Tomcat manager"
Enter your usename and password
In the next screen you can see section "WAR file to deploy". Select your web service war file and click deploy

Putting up jersey webservice + MySQL database live

Over the past two weeks i have been developing a jersey RESTful webservice and a MySql database that it communicates with. Now my Android application is done which gets it's resources from the webservice. During the whole development time i've had the webservice on a tomcat server on localhost. But now I need my service to go live.
And I dont even know where to start. How can I make it go live? What hosting companies are there that supports these demands and where do I start? How does the webservice -> database connection looks like on the hosting part? Is tomcat commonly used to host?
As you can see I got close to no knowledge about this and a wink in the right direction would be great!
What you need is a hosting service that supports Tomcat and MySql.
This what i found googling "tomcat hosting service", but there are a lot more.
You also might want a domain name (like www.mydomain.com). some hosting servies provide that as well.
I suggest you call them and ask them if they provide support for what you need.
Calling a remote service should be the same, all you have to do is change the url host, so instead of:
http://localhost
You'll put your domain:
http://mydomain.com

YAWS fronting Tomcat

Is there currently any easy way to set up a YAWS web server in front of Apache Tomcat Servlet container, similar to popular Apache httpd + Tomcat set up?
I do not believe there is an AJP connector for YAWS, but you should be able to front Tomcat with YAWS via HTTP. YAWS is relatively easy to setup as a reverse proxy. See the man page here for details (see revproxy):
http://yaws.hyber.org/yman.yaws?page=yaws.conf
Note: This is not yet considered production quality so you will want to do plenty of testing to ensure this satisfies your production requirements.
I do not know what your use case is, but you may find Nginx is a worthwhile alternative to Apache as a load-balanced, HTTP reverse proxy in front of Tomcat. There are a number of good tutorials for this on the web, or checkout the recent Linux Journal article (requires a subscription):
http://www.linuxjournal.com/article/10108

Categories

Resources