Amazon EC2 cloud hosting - apache

How do I host a http server at front, while multiple tomcat server behind it in EC2?
Do we need to do session and cookie management or does EC2 has it inbuild?
Can we stream images and static resources through some other server while dynamic content from tomcat?

Check out the Java support in AWS Elastic Beanstalk. It handles the load balancing, auto scaling, metrics and deployment for you. Deploy your static assets to S3 + CloudFront instead of keeping them inside your application bundle.

There are multiple ways to host a webserver in front and redirect requests to multiple tomcat servers in backend. Assuming you have webserver and multiple tomcat servers deployed over a EC2 and tomcat. Using ajp or mod_proxy or mod_jk, you can redirect requests hitting on your webserver to your backend tomcat servers.
By default, AWS does not provide cookie or session management. You can use AWS Elasticache for session management.
Yes, you can upload your images and other static content on Amazon S3 and deliver it from S3 itself or using CloudFront (CDN) while your dynamic requests are coming to your tomcat servers.
Your questions was too broad. If you provide more details, we can help more.
Thanks
Sanket

Related

Is fronting Tomcat by Apache http server meaningful when we are using aws application load balancer

I know fronting Tomcat by Apache has some security benefits when we are using aws classic load balancer. However, I was wondering if it is meaningful to front Tomcat by Apache http server, when we are using aws application load balancer? Because an application load balancer operates at Layer 7 of the OSI model, and deals with application-level content.
It depends on your intention. Fronting tomcat is not an issue when you go with AWS and ALBs are good way to handle and route your traffic. Therefore, stick to ALB rather than ELB and maintaining an Apache layer.

How to create subdomains using apache and aws elastic api?

In our current configuration we are having one ec2 aws instance. On this we are serving one api server which is developed using laravel and one front end which is developed using angular apache. And for dns resolution we are using godaddy. Now we are having one domain let's take it as example.com.
So what actually I need is serve angular application from example.com and laravel application from apis.example.com.
And I don't want to use aws route53 service as it will be paid service again.
So is there any way through which we can acheive it without using route53 and if not how should this be solved using route53.
The steps would be the same using Godaddy or Route53. There is really no reason to think that Route53 would be required in this case.
Assign an Elastic IP to your EC2 instance
Create A records in Godaddy (or any other DNS service you want to use) for both example.com and apis.example.com that point to the Elastic IP
Configure Apache on your EC2 instance to serve requests for example.com
Configure Apache on your EC2 instance to send requests for apis.example.com to your Laravel app

Does EC2 Elastic Load Balancer remove the need for apache/nginx?

I am striving for a very simple cloud based architecture on Amazon AWS. I would like to have an app layer of several "elastic" EC2 instances where my application (and application servers) run, but I'm wondering what the load balancing will look like.
If I choose to use ELB, does it remove the need for Apache or Nginx?
No. All the loadbalancer does is just that, distributes load across instances. Whatever your stack is running on each instance will still need a nginx or apache or whatever service you want to respond back to the request routed through the load balancer.
I'm assuming you're running a web stack needing some type of server like nginx, apache, or java needing tomcat or something.
However, if you want AWS to take care of nginx and/or apache, look into running as a ElasticBeanstalk application: https://aws.amazon.com/elasticbeanstalk/

sshing in aws load balancer and configuring it for subdomain routing?

We want to use Amazon Elastic BeanStalk service for deployment in EC2 Boxes.
We want to deploy our Ruby on Rails Application in such a way that we can do sub-domain based routing to different rails app.
And we want to use single SSL Certificate for our load balancer and want to configure our load balancer in susch a away tha subdomain based routing takes place.
HA Proxy does this work well but when we are trying to use Amazon Elastic BeanStalk service for our deployment, aws creates a load balancer but didn't associate it with any Key-Pair.
So we are not able to ssh in load balancer and add our configuration for subdomain based routing.
Can someone please point me to some solution ?
Thanks,
Ankit.
You don't SSH into AWS load balancers, they are basically a black box that you have only a limited set of configuration options for. You probably need to look at the Route 53 services for DNS routing.
Your configuration would have routing based on domain DNS to different load balancers, one for each separate service you need. You can't have a single ELB route traffic to different EC2 instances based on domain or URI fragments.

Glassfish 3.1 loadbalancing setup

I am very new to server setup. I have a cluster with 2 instances in GF.
instance1:28081
instance2:28082
I am running my GF in Amazon Linux EC2 instance. What are the options to create a load balancer setup that directs traffic to these instances when I try to access my EC2 instance http 80 port?
1) Do I need to have a webserver to direct traffic to these instances?
2) Is there any options in Glass fish which can handle load balancing without a webserver on these instances? I couldn't find load balancing configuration on my admin console.
3) Is there a way to use Amazon Load balancing to distribute traffic to these cluster instances which resides in a single ec2 instance?
If some one can provide step by step instructions/link reference that would be helpful.
I did a nice write up on loadbalancing/failover and proxy options for GlassFish.
have a look: http://blog.eisele.net/2012/01/throwing-light-on-glassfish-webserver.html