|
|
|
How to use apache to serve multiple applications using mod proxy |
Steps
1: Uncomment module in httpd.conf
2: Create two context in Tomcat for testing
3: Add ProxyPass entry to httpd.conf
4: Run
5: Use VertualHost directive
6: Run
1: Uncomment following lines from conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Note: If you forget to uncomment modules/mod_proxy_http.so following error will occur
proxy: No protocol handler was valid for the URL /App1/.
If you are using a DSO version of mod_proxy, make sure the proxy submodules are
included in the configuration using LoadModule.
2A: Change Tomcat server.xml. This is for testing and not required for actual setting
<Context path="/App1" docBase="C:/workspace/ServletApp/WebContent/" reloadable="true" crossContext="true"
privileged="true">
</Context>
<Context path="/App2" docBase="C:/workspace/ServletApp/WebContent/" reloadable="true" crossContext="true"
privileged="true">
</Context>
2B: /jsp/apache-mod-proxy.jsp This is for testing and not required for actual setting
<%
String ctx = request.getContextPath();
%>
<html>
<head>
<title>/jsp/apache-mod-proxy.jsp</title>
</head>
<body>
<form name="Servlet1" method="post" action="<%=ctx%>/Servlet1">
<h2><%=ctx%></h2>
</form>
</body>
</html>
3: Add ProxyPass entry to httpd.conf
<IfModule proxy_module>
ProxyPass /App1/ http://localhost:8080/App1/
ProxyPassReverse /App1/ http://localhost:8080/App1/
ProxyPass /App2/ http://localhost:8080/App2/
ProxyPassReverse /App2/ http://localhost:8080/App2/
</IfModule>
4: Run - Observe request is made and served through Apache for resource on Tomcat
URL: http://localhost/App1/jsp/apache-mod-proxy.jsp
URL: http://localhost/App2/jsp/apache-mod-proxy.jsp
Now let us try second scenario. You want to use URL like app1.mywebsite.com rather than www.mywebsite.com/app1. This can be
achieved using Apache VirtualHost directive.
5: Add VirtualHost and ProxyPass entry to httpd.conf
NameVirtualHost 127.0.0.1
<VirtualHost app1.mywebsite.com>
ProxyPass / http://localhost:8080/App1/
ProxyPassReverse / http://localhost:8080/App1/
</VirtualHost>
<VirtualHost app2.mywebsite.com>
ProxyPass / http://localhost:8080/App2/
ProxyPassReverse / http://localhost:8080/App2/
</VirtualHost>
6: Add entry to C:\WINDOWS\system32\drivers\etc\hosts file for testing
127.0.0.1 app1.mywebsite.com
127.0.0.1 app2.mywebsite.com
7: Run - Observe request is made and served through Apache for resource on Tomcat
URL: http://app1.mywebsite.com/jsp/apache-mod-proxy.jsp
URL: http://app2.mywebsite.com/jsp/apache-mod-proxy.jsp
|
|
|
| Wheat Cookies
|
 Wheat cookies is a healthy snack for your fussy toddler......
|
| Babyfood |
2010-Aug-26 |
| Wheat Cookies
|
 Wheat cookies is a healthy snack for your fussy toddler......
|
| Veg Recipes Baking |
2010-Aug-26 |
| Encoding special characters in userinput or on server
|
| Encoding can be done either in Javascript or JAVA encodeURIComponent, escape, java.net.URLEncoder..
|
| Java JSP |
2010-Aug-09 |
| Jstl fmt tag i18n formatdate formatcurrency
|
| fmt:setBundle, native2ascii.exe, fmt:message, fmt:setLocale, fmt:formatDate, fmt:formatNumber type=currency..
|
| Java JSP |
2010-Aug-05 |
| How to read and write a file
|
| How to read and write a file java.io.BufferedReader,java.io.FileReader, InputStreamReader ...
|
| Java J2SE |
2010-Aug-04 |
| jQuery validate form using ajax 2
|
| How to validate/submit form using ajax and jQuery input#, ($.ajax)..
|
| Javascript |
2010-Jul-23 |
| jQuery validate form using ajax 1
|
| How to validate/submit form using ajax and jQuery ($.ajax)..
|
| Javascript |
2010-Jul-23 |
| Dosa
|
  Masala dosa is my favourite South Indian dish and I relish it it whenever we go to a South Indian food joint......
|
| Veg Recipes Parathas |
2010-Jul-14 |
| Palak Sukka/Spinach Sukka/Palakachi Sukhi Bhaji
|
 .JPG) If you are looking for a palak recipe apart from aloo palak or palak paneer, which quick yet delicious you are at the right place......
|
| Veg Recipes Dry Veg |
2010-Jul-13 |
| How to create datasource in RAD Websphere
|
| Create JDBC provider, datasource and JAAS security setup, JDBC connection URLs
|
| Servers Websphere |
2010-Jul-08 |
| Get Started 4
|
| Struts2 framework structure, how various components fit together
|
| Java Struts2 |
2010-Jul-07 |
| How to populate a form when JSP is called first time
|
| This is achieved throught setting bean in request, using frameworks like Struts2, Spring3..
|
| Java JSP |
2010-Jul-07 |
| Spring3 And Hibernate 4
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
| Spring3 And Hibernate 3
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
| Spring3 And Hibernate 1
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
| Spring3 And Hibernate 2
|
| Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
|
| Java Spring |
2010-Jul-07 |
|
|