mod proxy, SSI and Options Includes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

 

Good day All.

 

We are having an issue - Server Side Includes are not working properly when the request is being proxy to Tomcat from Apache server. It is working only when we set the “Options +Includes” in the <proxy> element. Can you please suggest is the intended behavior.

 

When the Apache HTTP server is used standalone mode (means without using Tomcat), SSI is working properly.

 

Steps to reproduce:

In the Apache httpd.conf file,

1) Enable following modules.

                LoadModule include_module modules/mod_include.so

                LoadModule proxy_module modules/mod_proxy.so

                LoadModule proxy_http_module modules/mod_proxy_http.so

                LoadModule proxy_connect_module modules/mod_proxy_connect.so

2) Add "Includes" directive to the directory

                <Directory />

                                Options Includes Indexes FollowSymLinks

                </Directory>     

3) Add following configuration for proxy to Tomcat which is running at port 8080.

 

<IfModule mod_proxy.c>

                ProxyRequests Off

                ProxyPass / http://localhost:8080/

                ProxyPassReverse / http://localhost:8080/

</IfModule>

 

<Proxy *>

                Order deny,allow

                Allow from all

                Options +Includes

</Proxy>

 

4) Restart Apache server.

 

Changes to be done on Tomcat server:

1) Open the file \tomcat\conf\web.xml text editor.

2) Uncomment the ssi filter, which looks like below.

                <filter>

        <filter-name>ssi</filter-name>

        <filter-class>

          org.apache.catalina.ssi.SSIFilter

        </filter-class>

        <init-param>

          <param-name>contentType</param-name>

          <param-value>text/x-server-parsed-html(;.*)?</param-value>

        </init-param>

        <init-param>

          <param-name>debug</param-name>

          <param-value>0</param-value>

        </init-param>

        <init-param>

          <param-name>expires</param-name>

          <param-value>666</param-value>

        </init-param>

        <init-param>

          <param-name>isVirtualWebappRelative</param-name>

          <param-value>false</param-value>

        </init-param>

    </filter>

3) Uncomment the filter mapping, which looks like below.

                <filter-mapping>

                                <filter-name>ssi</filter-name>

                                <url-pattern>*.shtml</url-pattern>

                </filter-mapping>

4) Uncomment the mime mapping, which looks like below.

                <mime-mapping>

                                <extension>shtml</extension>

                                <mime-type>text/x-server-parsed-html</mime-type>

                </mime-mapping>

5) Go to \tomcat\webapps\ROOT directory, and create a below two files

                Create a file named main.shtml, with below content.

               

                                <HTML>

                                  <BODY>

                                                main.shtml

                                                <!--#include virtual="/sub.html" -->   

                                  </BODY>

                                </HTML>

 

                Create a file named sub.html, with below content.

               

                                <HTML>

                                  <BODY>

                                                sub.html<br>

                                                <!--#echo var="DATE_LOCAL"--><br>

                                                <!--#echo var="DATE_GMT"--><br>

                                                Good <!--#if expr="%{TIME_HOUR} <12" -->

                                                                                morning!

                                                                <!--#else -->

                                                                                afternoon!

                                                                <!--#endif -->

                                  </BODY>

                                </HTML>

 

6) Open the file \tomcat\conf\context.xml in text editor and add the attribute "privileged" to the context node, to look like below.

                <Context privileged="true">

7) Restart tomcat server.

 

 

Steps to test:

1) In the web browser request for the url http://localhost/main.shtml

2) It should show the content as below.

 

                                main.shtml sub.html

                                Thursday, 01-Nov-2018 12:39:44 India Standard Time

                                Thursday, 01-Nov-2018 07:09:44 GMT

                                Good afternoon!

 

3) One can note that SSI content from sub.html is included in the response above.

4) Open the httpd.conf file and remove the "Options +Includes" directive from the <proxy> node.

5) Restart Apache HTTP server.

6) Request the page again as in step-1, it shows below content.

                                main.shtml sub.html      

                               

                                Good morning! afternoon!

                               

7) From above, one can notice that SSI script kept inside main.shtml are honored but not honored which kept in the sub.html file.

8) One can also notice a warning in the log, saying-

                [client 127.0.0.1:54818] AH01374: mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed: /main.shtml

 

 

Similar to this, there was Bug 33089, where they used "Options +Includes" in the global level. But this also not documented. In the API, nowhere mentioned Options directive can be used at global level.

 

Questions:

1) Should we need to add Options +Includes in the <proxy> container to get proxy SSI to work?

2) As per docs, Options directive can be used in <directory> only. Is it also supposed to use at <proxy>?

 

 

Regards,

Rajesh

 


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux