Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
288 views2 pages

Nginx + Apache Tomcat Configuration Example

This document provides instructions for configuring Nginx as a reverse proxy to redirect traffic from port 80 to the Apache Tomcat server running on port 8080. It involves: 1. Configuring Tomcat to listen on port 8080 and set the document root path to "/apple". 2. Configuring Nginx to listen on port 80, set the root path to match Tomcat's "/apple" path, and redirect requests to port 8080. 3. Restarting both Tomcat and Nginx services for the changes to take effect.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
288 views2 pages

Nginx + Apache Tomcat Configuration Example

This document provides instructions for configuring Nginx as a reverse proxy to redirect traffic from port 80 to the Apache Tomcat server running on port 8080. It involves: 1. Configuring Tomcat to listen on port 8080 and set the document root path to "/apple". 2. Configuring Nginx to listen on port 80, set the root path to match Tomcat's "/apple" path, and redirect requests to port 8080. 3. Restarting both Tomcat and Nginx services for the changes to take effect.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Object 1

Nginx + Apache Tomcat configuration example


This tutorial shows you how to configure Nginx as a reverse proxy to redirect the traffics from port
80 to Apache Tomcat on port 8080.
Here is the environment in my Linode server :
1. Debian 7.5
2. Nginx 1.2.1
3. Tomcat 7.0.28
P.S Both Nginx and Tomcat are installed via apt-get install.

1. Tomcat Configuration
Edit server.xml, check the Tomcat listening port, and configure the default path to /apple
/etc/tomcat7/server.xml
<!-- Tomcat listen on 8080 -->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />

<!-- Set /apple as default path -->


<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<Context path="" docBase="apple">


<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

</Host>

Restart Tomcat, make sure when you access 127.0.0.1:8080, it will display the content in
127.0.0.1:8080/apple

2. Nginx Configuration
In Nginx, edit /etc/nginx/sites-enabled/default, put following content :
/etc/nginx/sites-enabled/default
server {
listen 80;
server_name yourdomain.com;
root /etc/tomcat7/webapps/apple;

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;
proxy_pass http://127.0.0.1:8080/;
}
}

It tells Nginx to redirect the traffics from port 80 to Apache Tomcat on port 8080. Done, restart
Nginx.

You might also like