Apache Server Side Includes - JSP WLS Plugin - apache

I am running Apache 249 and attempting to use SSI via a weblogic application.
I have added the following lines to my config file.
AddType text/html .jsp
AddOutputFilter INCLUDES .jsp
And have added the Options Includes both to the virtualHost and below.
<Directory "/apache/htdocs">
Options Indexes FollowSymLinks Includes
AllowOverride None
Require all granted
</Directory>
If I acces a test SSI file from within /apache/htdocs it works fine, however if I use a Location block using the Weblogic Plugin it doesn't work.
Any idea what I am missing here?

You need to use SetOutputFilter Includes within your Location Block that will process the .jsp file from the proxy before passing to the client, allowing the Virtual Include to work.

Related

Refreshing an Added Alias Directory to Apache's HTTPD

I'm exposing files using Apache's httpd <Directory> as below
Alias /getfiles "/web/playbooks/tmpfiles"
<Directory "/web/playbooks/tmpfiles">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
With this I'm able to access all files/folder inside /web/playbooks/tmpfiles through web browser URL like the below.
http://<server>:<port>/getfiles/<anyfile.txt>
Is it possible to refresh the above URL so I could see latest changes to files/folder inside /web/playbooks/tmpfiles periodically?
Any solution would be great.
You could try to make the client autorefresh by itself through instructions in the html itself instead of trying to do something weird which is not probably in the http spec. (I might be wrong).
For example, according to your directory entry, load module_autoindex module and then use this config:
<Directory /web/playbooks/tmpfiles>
Options Indexes MultiViews
IndexOptions FancyIndexing
IndexHeadInsert "<meta http-equiv=\"refresh\" content=\"10\">"
AllowOverride None
Require all granted
</Directory>
This way Apache httpd will add that tag in the html and the client will know it has to autorefresh the page each 10 seconds. Generally it is not recommended to set this too low, so perhaps 10 seconds and above is alright for you.

Testing CGI code on MacOS Sierra

I have some CGI code written in C that I've developed on an Ubuntu linux machine. It works fine, but I wanted to make some changes and update it while away on travel. Thought I'd set it up to test on my Mac laptop (macOS 10.12.1) using Xcode and Safari. Tried looking online for instructions on how to get apache to recognize the CGI code and found a few sites, but it still doesn't work.
Here's what I have so far:
I set up a directory /User/username/Sites to store the html pages that will call the CGI code through a form. (where "username" is my username)
I put the compiled CGI code in /Library/WebServer/CGI-Executables (Note: I also put them in /Users/username/Sites just in case)
Following the online instructions, in /etc/apache2/httpd.conf I uncommented the following lines:
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
AddHandler cgi-script .cgi
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Include /private/etc/apache2/extra/httpd-userdir.conf
Include /private/etc/apache2/extra/httpd-vhosts.conf
Also following the online instructions, I created the following file in /etc/apache2/users called username.conf (again, "username" is my username).
<Directory "/Users/username/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
When done with the above changes I restarted the apache server (also tried a full restart of the computer, but it didn't help).
I'm able to load the form page using http://localhost/~username/foo.html, but when I submit the form using the POST method to a code foo.cgi it just spits foo.cgi back at me and then safari dumps it in the download folder. Also tried writing a simple perl script and a simple cgi C code to just make a "hello world" web page and called it with http://localhost/~username/hello.pl (or .cgi). This gave me the same results, though for the perl script it spit the script itself back since it's just plain text.
There must be a step I'm missing, but haven't been able to find it. Any help would be greatly appreciated. Thanks!
DC
One step left out of the instructions I found online: need to also uncomment the line:
LoadModule cgi_module libexec/apache2/mod_cgi.so
in the httpd.conf file. Works now by putting the executables in the /Library/WebServer/CGI-Executables folder.
Besides all you did, I also added ExecCGI Includes to the Options line at the /etc/apache2/users/username.conf file. Restarted and worked. Config file looks like this:
<Directory "/Users/username/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks ExecCGI Includes
Require all granted
</Directory>

How to Set AllowOverride all

I want to set the AllowOverride all But I don't know how to do it. I have found the following code by searching the google and pasted it in .htaccess:
<Directory>
AllowOverride All
</Directory>
But after pasting it I started receiving "Internal Server Error"
Can anyone guide me where to put this code or how to do it?
In case you are on Ubuntu, edit the file /etc/apache2/apache2.conf (here we have an example of /var/www):
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change it to;
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
then,
sudo service apache2 restart
You may need to also do sudo a2enmod rewrite to enable module rewrite.
The main goal of AllowOverride is for the manager of main configuration files of apache (the one found in /etc/apache2/ mainly) to decide which part of the configuration may be dynamically altered on a per-path basis by applications.
If you are not the administrator of the server, you depend on the AllowOverride Level that theses admins allows for you. So that they can prevent you to alter some important security settings;
If you are the master apache configuration manager you should always use AllowOverride None and transfer all google_based example you find, based on .htaccess files to Directory sections on the main configuration files. As a .htaccess content for a .htaccess file in /my/path/to/a/directory is the same as a <Directory /my/path/to/a/directory> instruction, except that the .htaccess dynamic per-HTTP-request configuration alteration is something slowing down your web server. Always prefer a static configuration without .htaccess checks (and you will also avoid security attacks by .htaccess alterations).
By the way in your example you use <Directory> and this will always be wrong, Directory instructions are always containing a path, like <Directory /> or <Directory C:> or <Directory /my/path/to/a/directory>. And of course this cannot be put in a .htaccess as a .htaccess is like a Directory instruction but in a file present in this directory. Of course you cannot alter AllowOverride in a .htaccess as this instruction is managing the security level of .htaccess files.
Goto your_severpath/apache_ver/conf/
Open the file httpd.conf in Notepad.
Find this line:
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
Remove the hash symbol:
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Then goto <Directory />
and change to:
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Then restart your local server.
On Linux, in order to relax access to the document root, you should edit the following file:
/etc/httpd/conf/httpd.conf
And depending on what directory level you want to relax access to, you have to change the directive
AllowOverride None
to
AllowOverride All
So, assuming you want to allow access to files on the /var/www/html directory, you should change the following lines from:
<Directory "/var/www/html">
AllowOverride None
</Directory>
to
<Directory "/var/www/html">
AllowOverride All
</Directory>
If you are using Linux you may edit the code in the directory of
/etc/httpd/conf/httpd.conf
now, here find the code line kinda like
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
Change the AllowOveride None to AllowOveride All
Now now you can set any kind of rule in your .httacess file inside your directories
if any other operating system just try to find the file of httpd.conf and edit it.
As other users explained here about the usage of allowoveride directive, which is used to give permission to .htaccess usage. one thing I want to point out that never use allowoverride all if other users have access to write .htaccess instead use allowoveride as to permit certain modules.
Such as AllowOverride AuthConfig mod_rewrite Instead of
AllowOverride All
Because module like mod_mime can render your server side files as plain text.
enter code hereif you are using linux you have to edit the
`/etc/apache2/sites-available/000-default.conf`
under the Documentroot . add the following code
`<Directory /var/www/>
AllowOverride all
Require all granted
</Directory>`
then ,
`sudo service apache2 restart`
and you have to enable the apache mod rewrite
`sudo a2enmod rewrite`
I think you want to set it in your httpd.conf file instead of the .htaccess file.
I am not sure what OS you use, but this link for Ubuntu might give you some pointers on what to do.
https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles
I also meet this problem, and I found the solution as 2 step below:
1. In sites-enabled folder of apache2, you edit in Directory element by set "AllowOverride all" (should be "all" not "none")
2. In kohana project in www folder, rename "example.htaccess" to ".htaccess"
I did it on ubuntu. Hope that it will help you.
There are several answers but there a number of things wrong with this question and I would like to address these:
If you get an error (e.g. 500), look in the log files (if you have access to them). e.g. /var/log/apache2/ssl_error.log
e.g.
cat /var/log/apache2/ssl_error.log
[Tue Jun 01 19:05:34 2021] [alert] [pid 31154] config.c(2119):
[client *******] /var/www/mysite/public/tmp/.htaccess:
<Directory not allowed here [lid YLZo3quRlv2EKOAABVoFLwAAAIM]
Putting AllowOverrides in a .htaccess makes no sense and is not allowed. See Context. See also my explanation below. It should be defined in the Apache configuration (e.g. /etc/apache2)
Allowing everything is usually not the best idea. Be as restrictive as possible!
the Directory directive is missing a directory, should be e.g. <Directory /var/www/html/etc>
the Directory directive does not make sense in an .htaccess. The location of the .htaccess in a directory already has the effect of making the statements within apply to a specific directory
do not mix and match snippets that are intended to be put in the Apache configuration (e.g. in /etc/apache2/...) with statements that are intended to be put in .htaccess - though most of the time, they will be identical, there are some subtle differences
If you have the possibility to modify the Apache configuration directly, do not use .htaccess and deactivate it. (for performance reasons, among others. Also you can have all configuration in one place, put it in version control or manage it via a software configuration management tool, e.g. Puppet, Ansible, SaltStack)
Unless you really cannot access and modify the Apache configuration directly, you do not need .htaccess. This is a common misconception.
That you saw a 500 error proves my point. If you change configuration in the Apache configuration directly (and not in .htaccess), you will usually get an error message with an explanation and information about the error and the line number (e.g. when you do service apache2 reload or apachectl configtest) - which gives you the possibility to fix the error before applying this in production(!).
Also, look in the documentation. It is really quite good. For most directives, you can find where they apply (see "Context").
For example, for IfModule, you can see:
Context: server config, virtual host, directory, .htaccess
For, AllowOverrides it is:
Context: directory
Note the missing .htaccess in the Context!
Instead of googling for information which repeat the same mistakes over and over, look in the documentation!
Docs
AllowOverrides
https://www.danielmorell.com/guides/htaccess-seo/basics/dont-use-htaccess-unless-you-must
SuSE Linux Enterprise Server
Make sure you are editing the right file
https://www.suse.com/documentation/sles11/book_sle_admin/data/sec_apache2_configuration.html
httpd.conf
The main Apache server configuration file. Avoid changing this file. It primarily contains include statements and global settings. Overwrite global settings in the pertinent configuration files listed here. Change host-specific settings (such as document root) in your virtual host configuration.
In such case vhosts.d/*.conf must be edited
Plus those upvoted correct answers sometimes same error could be seen because of mismatched and different settings on SSL part of webserver configurations. (Obviously when not using .htaccess file).

WAMP virtualhost wont redirect

Ok I had to move my web to a new host. However new one is running Win 7 ultimate instead of 2008 R2.
To make sure i wont forget something moved over the existing WAMP Apache/PHP versions (bin folders).
It all works fine, except that virtualhosts simply wont redirect to the new documentroot.
it includes the virtualhosts conf file.
NameVirtualHost 88.159.116.217:90 should redirect to
C:/wamp/www/update/ but instead still directs to C:/wamp/www/
This setup worked fine on the 2008 R2. But now its simply ignoring everything defined in the included vhost.conf.
No errors (except that if my software connects to 88.159.116.217:90 - the files are not found since its root folder instead of update).
Code:
ServerAdmin hidden
ServerName hidden
DocumentRoot "C:/wamp/www/update/"
CustomLog logs/rfpatch.log combined
ErrorLog logs/rfpatch_err.log
<Directory "C:/wamp/www/update/">
Options -Indexes MultiViews FollowSymLinks IncludesNoExec
AllowOverride None
AddOutputFilter Includes html
Order allow,deny
Allow from all
AddType application/zip .tmp
AddType application/zip .cab
<Files update.dll>
AddType application/x-httpd-php .dll
</Files>
</Directory>
I don't need a hosts file - I'm not using domains.
There is no admin access problem (uac is also disabled).
the included vhost conf file is loaded - but vhost definitions are ignored.
The Apache version is the same as it was in the 2008 R2 server.
I can only think of two things...
You've not restarted Apache. It needs to be restarted for configuration changes to take effect.
Your Browser is caching the old page... Close all browser windows and tabs, then open the page and press CTRL-F5 to do a hard refresh. Also try clearing the browser cache data, it sometime "remembers" redirects and uses them over and over.

Server-side includes (SSI) stop working when on https (ssl)

My server side includes work fine when accessing the website through http, but when trying to access the site securely (which is all set up sweet) they just don't get included.
I'm using the following code in the one file inside my apache2/sites-enabled directory:
<Directory /var/www/html>
Options +Includes
AddType text/html .htm
AddOutputFilter INCLUDES .htm
</Directory>
Any ideas about where to look?
Got it. I had only put the above code into the virtualhost section for the ordinary port, not the ssl port.