I am trying to use Apache mod_include for SSI. I have a java application that is being served currently with Jetty. I have been able to get SSI working directly with Jetty but I'm now trying to have SSI enabled via Apache.
I am using mod_proxy to forward requests to Jetty. I assume I'm missing something here as even though the requests do forward to Jetty, the SSI tags are not being evaluated by Apache.
Current mod_proxy conf
ProxyRequests Off
ProxyPreserveHost On
ProxyStatus On
<Location /status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from localhost
</Location>
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
ProxyPass /prototypeWebApp http://localhost:8080/prototypeWebApp
#ProxyPassReverse /prototypeWebApp http://localhost:8080/prototypeWebApp
Under webapp directory I have a single file apacheSSI.shtml with the following contents:
<!--#include virtual="/prototypeWebApp/apacheSSI.html" -->
Related
I am trying to configure an external Apache front-end with a different URL to the backend tomcat app. I take tomcat's manager app as an example.
I would like users to access my page like externally like:
https://myhost.com/tomcat-manager
Internally, it gets redirected to
http://localhost:8080/manager
I tried the following configuration in apache2 with mod_proxy and mod_rewrite:
RewriteEngine on
SSLProxyEngine on
RewriteRule "/manager/(.*)$" https://myhost.com/tomcat-manager/$1 [P]
ProxyPass /tomcat-manager http://localhost:8080/manager
ProxyPassReverse /tomcat-manager http://localhost:8080/manager
It mostly works, but I dislike that the tomcat manager webapp outputs its links as "/manager" instead of "/tomcat-manager", forcing me to add the above mod_rewrite rule. Ideally, I would like the end-user to see only browser URLs of the pattern:
https://myhost.com/tomcat-manager/(whatever)
and never the following:
https://myhost.com/manager/(whatever)
Any suggestion to configure Apache without modifying the underlying webapp? Thanks!
I found the answer to my question. It is Apache's mod_proxy_html. I enabled the corresponding modules and fixed Ubuntu's mod_proxy_html missing configuration as stated here: https://serverfault.com/questions/684905/proxyhtmlurlmap-not-working-in-apache2-4
Then, I added the following configuration code:
ProxyHTMLEnable On
ProxyHTMLURLMap http://localhost:8080/manager/ /tomcat-manager/
ProxyHTMLURLMap /manager/ /tomcat-manager/
SetOutputFilter proxy-html
RequestHeader unset Accept-Encoding
And that's it. Now, I can access http://myhost.com/tomcat-manager and the html code within is also rewritten!
I have a Java application deployed on Oracle Weblogic server which can be accessed via http://www.example.com/myapp
This works fine but now I want to get rid of "myapp" in the URL so the application can be accessed only via http://www.example.com
Is this possible? If yes, how?
I don't know about Weblogic but in JBoss and Tomcat you'd name your application ROOT.war.
IMHO this is not desirable so I'd employ some URL rewriting, e.g. by using an intermediate apache webserver, which then forwards /myapp(/.*) to $1.
Of course you'd have to remove the context root from any internally generated links, but how that is done would depend on your application and environment.
I deploy a Reverse Proxy, you can use Oracle HTTP Server or Apache for this, I use mod_wl_ohs in the OHS and it's pretty simple:
<VirtualHost *:80>
ServerName myexample.com
<IfModule weblogic_module>
DynamicServerList On
WebLogicHost <IP of the weblogic>
WebLogicPort <PORT>
<Location />
RedirectMatch ^/$ /store
SetHandler weblogic-handler
WebLogicHost <IP of the weblogic>
WebLogicPort <PORT>
</Location>
</IfModule>
</VirtualHost>
Plus, it'll give you another security layer if you setup and URL-Firewall using REWRITE mod.
<context-root> in application.xml needs to be set to / like this:
<web>
<web-uri>web.war</web-uri>
<context-root>/</context-root>
</web>
Further reading:
Weblogic Docs on context-root
Similar question on SO
As part of trying to make an AJAX site crawlable, I wish to redirect URLs containing "_escaped_fragment_" to Tomcat.
I currently make Apache serve the root resource "/" but if the resource "/?_escaped_fragment_=" is requested then it should redirect the request to Tomcat so that the crawler servlet can service it.
It seems to me that you can not do that in mod_jk.conf
You could use an Apache rewrite rule to transform the URL in a format that will be easier to forward to Tomcat using mod_jk:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(_escaped_fragment_=.*)
RewriteRule ^/$ /crawler/?%1 [L,R=permanent]
The above rule would only apply when the query string starts with _escaped_fragment_= and it will transform this URL:
http://host/?_escaped_fragment_=home
Into this one:
http://host/crawler/?_escaped_fragment_=home
You can then use the usual JkMount directive to forward /crawler to Tomcat, e.g.:
JkMount /crawler* ajp13_worker
This question already has answers here:
How to change the port of Tomcat from 8080 to 80?
(14 answers)
Closed 9 years ago.
I have a webapp on my tomcat server like this:
mydomain.com:8080/mywebapp
Then I connect to my webapp, and it is working correctly, but what I want is to see my webapp like this:
mydomain.com
So I don't want only tomcat on port 80, I don't want to access my webapp through its name, I want to connect directly using my domain URI.
How can I do this? I want this to work with Linux (Ubuntu 12.04 LTS) and Windows servers.
There are several ways to achieve this, but the most common way to solve it is to run Apache as a reverse proxy in front of it. You can find some details here. This will work on both Linux and Windows. For Linux, you can also use authbind to allow Tomcat to bind to port 80.
Just changing the port to 80 in your server.xml will not work in Linux, since it would require you to start Tomcat as root, which is not a very good idea.
Also, to have your webapp at /, you can deploy your war file as ROOT.war.
Running any application on a privileged port (those below 1024) requires special privileges. If you do this, you should ensure your instance is properly hardened.
To configure the port tomcat listens on you have to modify the HTTP connector in conf/server.xml (server reference documentation):
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
To change the context path of an app, you can rename the war file. To deploy it at the root, rename your war file to ROOT.war. Or you can add a META-INF/context.xml in which you can specify the desired context path (context reference docs):
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/" />
You need to set apache webserver and configure it to use tomcat.
You need to use mod_jk in order to configure apache webserver to communicate with tomcat.
Use this link to set up the mod_jk.
I am also finding tough to categorize this question. So please bear with me to explain the issue.
We have two different applications:
PHP on XAMPP and
Java on Tomcat
Now we have a business case to merge both the products. ie., PHP product should be looking no different from the Java application and also it should be part of Java app. (appears in the one of the tab in Java app)
The CSS part can be taken care. But the complex part is how to collate these two application?
Also we are using Tomcat for Java and Apache for PHP,
in such case how do we bundle the product as one.
I tried googling, but most of them point to having apache and tomcat connector etc.
But I am still not clear on how to achieve this seamless integration.
Misc Info:
--- Java App: DB: MySQL, Maven, Servlet, Spring, Struts, Hibernate
--- PHP App: XAMPP (or somecases LAMP)
Please let me know if I had missed out any details.
The two applications served via apache should not be a problem look at mod_jk This will mean your java web app is still running on tomcat which it has to do anyway.
Maybe this tutorial will help. Though I haven't tried it myself so I can't say for sure.
I am able to get Apache talk to Tomcat through mod_proxy.
I actually referred to the below links to get this working (mostly changes to httpd.conf in Apache and server.xml in Tomcat):
http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html
http://confluence.atlassian.com/display/DOC/Using+Apache+with+mod_proxy
http://publib.boulder.ibm.com/infocenter/cqhelp/v7r0m0/index.jsp?topic=/com.ibm.rational.clearquest.webadmin.doc/rwp/t_config_mod_proxy_support.htm
I then configured PHP with Apache following [this link][1] and got the PHP configured with Apache.
So as a test program, I am able to reach servlet programs (Tomcat) from a Apache like http://localhost/example/servlet then access PHP programs too with a URL like http://localhost/phptest
ZeissS, Paul and Vincent. Thanks all for your help. Even though I have a long way to go, this looks like the starting point.
=== httpd.conf in Apache server ===
# enable the below or add new
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
# Start Modules for PHP
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "c:/windows"
# Just at the end of 'Main' server configuration - add the below
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /examples http://localhost:8080/examples/
ProxyPass /servlets http://localhost:8080/examples/servlets/
ProxyPass /jsp http://localhost:8080/examples/jsp/
ProxyPassReverse /examples http://localhost:8080/examples/
# Finish Modules for PHP
=== server.xml in Tomcat ===
<!-- searched the below connector port=8080 and I replaced that tag with the below -->
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
proxyName="http://localhost" proxyPort="80"/>