How to include files outside the document root

I want to show the contents of my /etc/rc.d/rc.firewall script in a web page. In httpd.conf I have:
Alias /firewall /etc/rc.d/rc.firewall
<Directory /etc/rc.d>
Order allow,deny
Allow from all
</Directory>

Open in new window

In my html I have:
<html><body><h1>FIREWALL: It works!</h1>
<pre>
<!--#include virtual="firewall" -->
</pre>
</body></html>

Open in new window

Both mod_include and mod_alias are loaded. the html and /etc/rc.d/rc.firewall are both executable. "Options Includes" is specifed in my <Directory /srv/httpd/htdocs> (document root).

It doesn't work. Can someone tell me the right way to do this?
LVL 1
jmarkfoleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
I doubt that it will work.  Those files are owned by 'root' and Apache will never have the permissions to access them.  The only web software I know of that can show things like that is Webmin and it is actually a Perl program with a web interface.  I'm not sure but I think it installs under 'root' so it has permissions to do things like that.
0
jmarkfoleyAuthor Commented:
Those file have a+r access, so it should work.

To eliminate that possibility, how about accessing a file in my home folder: /home/mfoley/hello.txt. I've reconfigured httpd.conf

Alias /howdy /home/mfoley/hello.txt

<Directory /home/mfoley>
Order allow,deny
Allow from all
</Directory>

Getting the message: "You don't have permission to access /howdy on this server."
0
Dave BaldwinFixer of ProblemsCommented:
And that is because you are trying to access it as the Apache user when you go thru the web site.  You can enable 'per user' web sites in the 'public_html' directory... but that still will only allow access to files under that directory under the Apache user.  As you may be gathering, Apache is intended to restrict you to files in the 'web root'.  The Apache user is very limited and that is on purpose.

You can access files in your 'public_html' directory (after setting it up in httpd.conf) under your own user if you also install 'su_exec'.  http://httpd.apache.org/docs/2.2/suexec.html

For comparison, all the things you have tried would work on Windows.  Which is kind of a comparison of the security differences between Linux and Windows.
0
jmarkfoleyAuthor Commented:
I figured out a solution. This did the trick in httpd.conf (the 'Require all granted' was key):

Alias /firewallRC /etc/rc.d/rc.firewall

<Directory /etc/rc.d>
Order allow,deny
Allow from all
Require all granted
</Directory>

Then, in the html file I have:

<!--#include virtual="firewallRC" -->

That brings up my current rc.firewall script!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jmarkfoleyAuthor Commented:
I figured it out
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.