Redirect Apache Request to Tomcat
2012-06-18 14:52
323 查看
If we want to access website by domain name without entering any port no than we can access that website by port 80 but unlike PHP which runs on HTTP Web Server; Java based websites run on 8080 which is default port for Apache Tomcat. In this article we will
learn on how we can redirect Apache request to Apache Tomcat.
Software Requirement:
Apache Web Server(httpd) 2.2+
Apache Tomcat 5.5+
Configuring Apache Web Server
I am assuming that you have already installed Apache Web Server and Apache Tomcat in the system. Now open httpd.conf located inside [Apache Web Server Folder]/conf/httpd.conf. Check for mod_proxy.so and mod_proxy_ajp.so. The line that you are looking at will
look something like:
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
Uncomment the above line by removing the hash from start.
AJP Port Configuration in Apache Tomcat
Now we will be checking the AJP port used inside Apache Tomcat, we can find this inside [Apache Tomcat Folder]/conf/server.xml. Check for following lines.
<connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
The port no may change if you have changed any configuration otherwise you can search for “AJP” word. If you found the above line you will notice that the AJP port in use is 8009. Now we would be using this port no inside httpd.conf, for redirecting port 80
request to port 8009.
Redirect Apache Request to Apache Tomcat
After uncommenting the mod proxy module, now it’s time to add the entry for redirection and for this go to bottom of httpd.conf file and add following lines.
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
The above statement says that redirect all request from port 80 to Tomcat ROOT folder(Assuming you have deployed your website inside ROOT folder). But if you want to redirect request to multiple application than will have to modify the above code to add the
application name.
ProxyPass /app1 ajp://localhost:8009/app1
ProxyPassReverse /app1 ajp://localhost:8009/app1
ProxyPass /app2 ajp://localhost:8009/app2
ProxyPassReverse /app2 ajp://localhost:8009/app2
ProxyPass /app3 ajp://localhost:8009/app3
ProxyPassReverse /app3 ajp://localhost:8009/app3
Here if you see if i set the ProxyPass for three applications app1, app2 and app3. In simple words it says that redirect all request that has /app1 in URL to app1 application deployed in Apache Tomcat.
相关文章推荐
- Configure ubuntu apache to forward the request to tomcat app
- EM11g: How to discover and monitor Tomcat apache server?
- java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to org.spri
- Tomcat启动报错:org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalin
- org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHo
- hadoop错误org.apache.hadoop.yarn.exceptions.YarnException Unauthorized request to start container
- tomcat org.apache.catalina.LifecycleException: Failed to start component
- A Simple Step-By-Step Guide To Apache Tomcat SSL Configuration
- The Apache Jakarta Tomcat 5 Servlet/JSP Container--Realm Configuration HOW-TO
- Tomcat启动报错或警告: org.apache.catalina.webresources.Cache.getResource Unable to add the resource
- Tomcat启动报错:org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalin
- How to Configure Tomcat/JBoss and Apache HTTPD for Load Balancing and Failover
- Unable to load configuration. - bean - jar:file:/D:/apache-tomcat-8.0.30/web
- Tomcat-Apache HOWTO Tomcat+Apache HOWTO
- Tomcat启动报错或警告: org.apache.catalina.webresources.Cache.getResource Unable to add the resource
- AM org.apache.catalina.realm.LockOutRealm authenticate WARNING: An attempt was made to authenticate the locked user "tomcat"
- Tomcat7出现HTTP Status 500 - java.lang.ClassCastException: org.apache.jasper.el.ELContextImpl cannot be cast to org.apache.jasper.
- hadoop错误org.apache.hadoop.yarn.exceptions.YarnException Unauthorized request to start container
- How to Install Apache Tomcat 8 (on Windows, Mac OS X, Ubuntu) and Get Started with Java Servlet Prog
- How to Move SSL certificate from Apache to Tomcat