Nginx Apache Tomcat


This blog entry is the third and last part of the series „Create APEX in AWS“. Here I describe the installation and configuration of Apache Tomcat and the deployment of the ORDS application in Tomcat. Later I will explain the installation of the Webserver Nginx and configure it to access APEX via Apache Tomcat and ORDS.

Previously, you could only run an Apache proxy server with Tomcat. In order to use the Nginx proxy server with Tomcat, your Elastic Beanstalk environment must be running platform version 2.1.5 or above. Today, I am writing this article on how to configure Nginx for RTSP to HLS streams and both Apache 2 and Apache Tomcat for HLS streams. We have many ways to convert RTSP streams to HLS streams.

Information about the installation of the APEX application in AWS can be found here. The installation and configuration of Oracle Data rest service is described here.

  1. How developers use Apache HTTP Server, NGINX, and Apache Tomcat MaxCDN uses NGINX The original API performed a synchronous Nginx reload after provisioning a zone, which often took up to 30 seconds or longer.
  2. The gap between Apache and Nginx was still 6.6% one year ago. The Cloudflare Server at rank 3 is particularly interesting in that context, as it is derived from Nginx. So are two more web server in the top 15, namely Tengine and ArvanNginx. If we combine all these Nginx-based technologies, they occupy a very impressive 52.4% of the market.

Installation Apache Tomcat on the EC2 Container

As root: Download and extract the software:

[[email protected]<ec2-container>]# cd /usr/local

[[email protected]<ec2-container>]# wget

[[email protected]<ec2-container>]# tar -xvf apache-tomcat-9.0.20.tar.gz

[[email protected]<ec2-container>]# mv apache-tomcat-9.0.20 tomcat9

Create the Linux Service for the Tomcat. It is necessary for the automatically start and stop of the Tomcat by the Server reboot. Create the File tomcat.service:

[[email protected]@<ec2-container>]# vi /etc/systemd/system/tomcat.service



Description=Apache Tomcat Web Application Container






Environment=’CATALINA_OPTS=-Xms512M -Xmx1G‘











*Note: for the production environment the tomcat should be started from non-privileged user! In my test case I will start and top the tomcat as the user root.

Enable Service tomcat and start it:

[[email protected]<ec2-container>]# systemctl enable tomcat

[[email protected]<ec2-container>]# systemctl start tomcat

Check if Tomcat is running and accessible from the Browser:

Configure Apache Tomcat for the access APEX via Oracle Rest Data Service (ORDS)

Copy the Java binary ords.was and apex images into Tomcat directory:

[[email protected]<ec2-container>]# cp /home/apexuser/ORDS/ords.war /usr/local/tomcat9/webapps/

[[email protected]<ec2-container>]# mkdir /usr/local/tomcat9/webapps/i

[[email protected]<ec2-container>]# cp -Rf /home/apexuser/apex/images/* /usr/local/tomcat9/webapps/i

Change the permissions for the ORDS Directory for the user tomcat (created during the tomcat installation):

As root:

[[email protected]<ec2-container>]# chmod -R 777 /home/apexuser/ORDS/ords/conf/

Restart the Apache Tomcat:

[[email protected]<ec2-container>]# systemctl restart tomcat

Test the access to APEX via Apache Tomcat:

It works!

Install Nginx HTTP Server:

[[email protected]<ec2-container>]# amazon-linux-extras install nginx1.12

[[email protected]<ec2-container>]# systemctl enable nginx

[[email protected]<ec2-container>]# systemctl start nginx

Check the availability of nginx in Browser:

Configure Nginx to forward requests from Tomcat-ORDS-APEX

Check the Public Hostname/IP Address of the EC2 Container in the AWS Console:

Create the Cache Directory:

[[email protected]<ec2-container>]# mkdir -p /var/cache/nginx/one

Create the File default.conf.

[[email protected]<ec2-container>]# vi /etc/nginx/conf.d/default.conf

File Content:

proxy_cache_path /var/cache/nginx/one levels=1:2 keys_zone=one:128m;

server {

listen 80;

listen [::]:80;

server_name <Public Servername or Ip Address of EC2>;

proxy_cache one;

location / {

proxy_set_header X-Forwarded-Host $host;

proxy_set_header X-Forwarded-Server $host;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;




Save the file and check the nginx configuration:

Nginx apache tomcat tutorial

[[email protected]<ec2-container>]# nginx -t


Nginx Reverse Proxy For Apache Tomcat

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

Reload nginx configuration:

[[email protected]<ec2-container>]# nginx -s reload

Apache/tomcat Nginx Haproxy

Test Apex via Nginx (Port 80):

http://<Public IP of EC2 Container>/ords/

It works!!!

Dropbox free download

Apache Tomcat Nginx 区别

Previously Blog posts in this series: