Strange CSS/Apache problem - apache

I have been trying to install ReviewBoard and all looks like it has gone well, in as much as I can access the site and functionality
However, I have strangeness where no style sheet appears to be applied for some reason.
I suspect it may be a permissions issue on a folder that it can't access or some Apache setup error I have made.
Is there any Apache configuration that could have caused this?
Has anyone experienced any similar problems not just for ReviewBoard?
Further info: It looks like Apache is receiving the request for the Stylesheets
[20/May/2009:10:00:35 +0100] "GET /reviewboard/media/rb/css/common.css?1242747706 HTTP/1.1" 404 2512
[20/May/2009:10:00:35 +0100] "GET /reviewboard/media/rb/css/ie_hacks.css?1242747706 HTTP/1.1" 404 2514
[20/May/2009:10:00:36 +0100] "GET /reviewboard/media/rb/js/csshover2.htc?1242747706 HTTP/1.1" 404 2514
[20/May/2009:10:00:36 +0100] "GET /reviewboard/media/rb/js/pngfix.htc?1242747706 HTTP/1.1" 404 2511
EDIT: Looking at the access logs the GET for the CSS is actually 404-ing as the path should be reviewboard/htdocs/media/rb/css/* (although there is an alias in the HTTP.conf that I assumed dealt with this.
EDIT: The .htaccess file contains
<IfModule mod_expires.c>
<FilesMatch "\.(jpg|gif|png|css|js|htc)">
ExpiresActive on
ExpiresDefault "access plus 1 year"
</FilesMatch>
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
EDIT:
The httpd.conf sections looks like this
<VirtualHost *:8080>
ServerName FASKALLYRB
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/reviewboard/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
ErrorDocument 404 /errordocs/500.html
# Serve django pages
<Location "/">
PythonPath "['C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/reviewboard/conf'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE reviewboard.settings
SetEnv PYTHON_EGG_CACHE "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/reviewboard/tmp/egg_cache"
SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonAutoReload Off
PythonDebug Off
# Used to run multiple mod_python sites in the same apache
PythonInterpreter reviewboard_reviewboard
</Location>
# Serve static media without running it through mod_python
# (overrides the above)
<Location "reviewboard/media">
SetHandler None
</Location>
<Location "reviewboard/errordocs">
SetHandler None
</Location>
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/reviewboard/htdocs">
AllowOverride All
</Directory>
# Alias static media requests to filesystem
Alias reviewboard/media "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/reviewboard/htdocs/media"
Alias reviewboard/errordocs "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/reviewboard/htdocs/errordocs"
</VirtualHost>

The URL for Location and Alias directives can't be relative and needs a leading slash. Thus you should be using '/reviewboard/.......'.
FWIW, the PythonInterpreter directive isn't used for what your comment against it seems to indicate you think it does.
# Used to run multiple mod_python sites in the same apache
PythonInterpreter reviewboard_reviewboard
The application is always run within same Apache instance. What PythonInterpreter does is allow you control which Python sub interpreter within each Apache server child process it runs. It is actually redundant in your case, as the same sub interpreter is by default used for all mod_python hosted applications under the same VirtualHost. Note that there will still be multiple instances of the application, on in each of the Apache server child processes.

You could make a symlink in reviewboard called 'media' that points at htdocs/media perhaps.
Alternatively:
move htdocs/media to ..
or go into the reviewboard code and tweak the url generating code
or if you have mod_rewrite installed you could redirect requests to the right place

Related

Apache 2.4 compression not working when using alias and reverse proxy

Problem:
I have an alias directory for a url sub path that pulls static data. I can get this to gzip compress just fine. However, when I add proxy to other paths and add an exception for my static data, compression stops.
Environment
Windows x64
Apache 2.4
Key Configuration in httpd.conf
<Directory "${SRVROOT}/static">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# I have used FilterProvider as well an know this just does javascript at the moment
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
SetOutputFilter DEFLATE
<IfModule alias_module>
Alias "/static" "${SRVROOT}/static"
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
</IfModule>
With this configuration and a "static" folder under SRVROOT, I place a file bundle.js (3M of data). Polling this file at http://localhost/static/bundle.js gives me 600K of download with gzip compression. ALL GOOD
Now for the change. The default path of the app needs to reverse proxy to another application and apache is just serving up static content.
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
extra/proxy-html.conf file content
#default proxy stuff above...
ProxyRequests off
ProxyPass / http://localhost:5000/
#ProxyPass /static/ /
ProxyHTMLURLMap http://localhost:5000/ /
<Location />
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap / /
RequestHeader unset Accept-Encoding
</Location>
<Location /static/ >
ProxyPass !
</Location>
This still allows me to hit my static data, only now the gzip compression is not happening. I do not know if this is a bug in apache or if there is a better way to configure this.
Here are my requirements:
I cannot change the pathing of the url (static is where it is, and root url content gets reverse proxied
I need compression
Deployment is to a root folder that honestly is not named static, so the fact that I route (in this example) static to {some directory}/static it is really http://localhost/static/* to a dist folder in all actuality.
It appears that RequestHeader unset Accept-Encoding is bleeding over into the other Location definition. This seems like it should not be expected behavior. There appears to be two solutions to the problem.
Remove the ProxyHTMLURLMap and RequestHeader unset Accept-Encoding as this needs to uncompress the content
to do the url rewriting.
Inflate and Deflate the content. I have yet to determine of this will inflate and deflate the static content on the server. The only reason I mention this is because the usetting of the Accept-Encoding seemed to bleed over into the static section. -- Not sure how to test this yet.
Example of removing ProxyURLMap
ProxyRequests off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
<Location /static/ >
ProxyPass !
</Location>
#Do not use this anymore
#<Location />
# ProxyPassReverse /
# ProxyHTMLEnable On
# ProxyHTMLURLMap / /
# RequestHeader unset Accept-Encoding
#</Location>
Example of using the INFLATE;DEFLATE
ProxyRequests off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
<Location />
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap / /
SetOutputFilter INFLATE;DEFLATE
</Location>
<Location /static/ >
ProxyPass !
</Location>

Apache proxy gzip

I am using Apache 2.4 as a proxy server. All requests that have myapp are being redirected to tomcat that serves files. I am using mod_proxy.so(proxy) and mod_deflate.so (gzip). In my httpd.config (Apache config) this is what I have:
ProxyPass /myapp/ http://myserver:58080/myapp/
<Location /fusebox/>
ProxyPassReverse /myapp/
RequestHeader unset Accept-Encoding
#SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml text/javascript application/x-javascript application/x-httpd-php
</Location>
Do you have any suggestions why this is not working?
Thank you
Sorry about the short answer, but I'm just passing by in a hurry.
Your proxypass-directive is likely working og Apache is likely serving out content from your Tomcat (if your Tomcat is healthy).
Your proxypassreverse-directive, requestheader and outputfilter are unlikely to be doing anything since they are contained in a location-directive not related to your proxypass. Loose the location-tags and things are going to happen.
Kind regards,
Helge

.htaccess being ignored - Ubuntu 14.04

I'm trying to use the .htaccess file on my Apache server.
Here is what my .htaccess looks like
# 1 YEAR
<FilesMatch "\.(ico|svg|woff|eot|ttf)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|png|gif|css|js)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType font/x-woff .woff
AddType image/svg+xml .svg
# Compress compressible fonts
AddOutputFilterByType DEFLATE font/ttf font/otf image/svg+xml
I enabled mod_rewrite using a2enmod rewrite
The tutorials I followed told me to edit the file in /etc/apache2/sites-available/default but there isn't a file by the name default in that folder. There was a 000-default.conf instead in the same path. But that file didn't have the part
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
which I'm supposed to edit.
This is the contents of 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
However /etc/apache2/apache2.conf had the exact same part. So I replaced AllowOverride None over there to AllowOverride All. I restarted the server after that.
However the .htaccess file is still not being loaded. If I add gibberish to the .htaccess file everything still works fine meaning it didn't get loaded.
What did I miss here?
First of all, the name of the file doesn't really matters. 000-default.conf, while not really common seems good to me.
Modify your site configuration
There are 2 major things you have to consider when serving .htaccess files :
AccessFileName .htaccess
AllowOverride All
As said in the apache2 doc, you must declare AllowOverride in a Directory section. That's why it didn't work when setting it in main config file.
I'd advise you to just paste those 4 lines in /etc/apache2/000-default.conf inside the Virtualhost section and it should work:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
(assuming your root directory is /var/www)
You don't have to set AccessFileName as default is .htaccess.
If it doesn't work and you have more than 1 file in /etc/apache2/sites-available
Apache might use another config thant 000-default.conf. Just check which of those are symlinked to /etc/apache2/sites-enabled. If there's still more than 1, you might want to disable every other enabled site just to be sure.
If it still doesn't work, just check file ownership & permissions.
The isssue was that I was placing the .htaccess file in /var/www/ while my DocumentRoot for my website was pointing to a different directory. Moving the .htaccess file to that folder solved the issue.

Apache not processing basic SSI

The web server is Apache 2.2.22 running on Ubuntu 12.04 LTS.
This is my http.conf file:
DirectoryIndex index.shtml index.html index.cgi index.pl index.php index.xhtml
LoadModule cgi_module /usr/lib/apache2/modules/mod_cgi.so
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
AddHandler cgi-script .cgi .pl
LoadModule include_module /usr/lib/apache2/modules/mod_include.so
<Directory "/var/www">
Options +Includes
AddHandler server-parsed .shtml
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
XBitHack on
</Directory>
According to this http://httpd.apache.org/docs/current/mod/mod_include.html I need to have the AddType entry (got it), the AddOutputFilter entry (got it), and the Options +Includes entry (got it). It says I need to put that in a section (got it).
According to this http://httpd.apache.org/docs/current/howto/ssi.html I need Options +Includes (got it), AddType (got it) AddOutputFilter (got it), and XBitHack On may help.
This is the /var/www/index.shtml file:
<html>
<body>
<p>The current date is <!--#echo var="DATE_LOCAL" --></p>
</body>
</html>
The permissions on that file are set to -rwxr-xr-x.
When I load the file in my web browser, it loads and renders fine but the SSI part is not processed. All I see is "The current date is".
Here's the entry from /var/log/apache2/access.log:
10.0.2.2 - - [05/Oct/2013:16:57:07 +0000] "GET /index.shtml HTTP/1.1" 200 401 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36"
Here is the error from /var/log/apache2/error.log:
[Sat Oct 05 16:57:07 2013] [warn] [client 10.0.2.2] mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed
Options +Includes wasn't set? I see it right there in my http.conf file. I Googled around but couldn't figure out what the problem is.
The solution is to place the directives shown at the beginning of this web page in a Directory section, but not place them in the http.conf file. Instead they belong in the sites-available/default file.
This was sufficient to get it working:
<Directory "/var/www">
# ... other stuff appears here
# add the three lines below:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Options +Includes
</Directory>
Quick addition: For MACOS Mojave, place these directives into ‎⁨
Macintosh HD⁩ ▸ ⁨private⁩ ▸ ⁨etc⁩ ▸ ⁨apache2⁩ ▸ ⁨users⁩▸ {username}.conf

Mono IOMAP case sensitivity

Having some problems installing BlogEngine.NET onto my CentOS mod_mono 2.8 (mono 2.8.1) box.
The BlogEngine.NET code references a folder named 'Bin'. On looking at the contents of the directory, there is a folder called 'bin' - the normal place for the compiled source to reside.
Renaming the folder to 'Bin' is not an option, as this will cause mono problems (it requires the folder to be called 'bin').
I came accross this: http://www.mono-project.com/IOMap
Which suggests that IOMap in Mono will make mono 'ignore' case sensitivity.
I added MONO_IOMAP=all to my env, from su, and it appears when I call env However, this doesn't seem to work - it is still case sensitive.
I then added MonoSetEnv MONO_IOMAP=all to my apache vhosts file for a specific subdomain, and this still doesn't work.
Any ideas what I am doing wrong? Am I being blind and not adding MONO_IOMAP=all to env for any other users than root?
Update: My hosts.conf for this site looks like:
<VirtualHost *:80>
ServerAdmin webmaster#host.net
DocumentRoot /home/host/www/host.net/blog
ServerName blog.host.net
ErrorLog /home/host/www/host.net/logs/blog.host.net-error.log
TransferLog /home/host/www/host.net/logs/blog.host.net-access.log
CustomLog /home/host/www/host.net/logs/blog.host.net-access_combined.log combined
DirectoryIndex index.html index.aspx
MonoServerPath blog.host.net "/usr/local/bin/mod-mono-server2"
MonoExecutablePath blog.host.net "/usr/local/bin/mono"
MonoDebug blog.host.net true
MonoSetEnv blog.host.net MONO_IOMAP=all
MonoApplications blog.host.net "/:/home/host/www/host.net/blog"
<Location "/">
Allow from all
Order allow,deny
MonoSetServerAlias blog.host.net
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>
</VirtualHost>
Try to set MonoSetEnv with server alias, for example my configuration of virtual host looks like this:
DocumentRoot /var/www/my.domain.com/
ServerName my.domain.com
MonoServerPath mydomaincom /usr/local/bin/mod-mono-server4
MonoSetEnv mydomaincom MONO_IOMAP=all
AddMonoApplications mydomaincom "/:/var/www/my.domain.com/"
<Location />
Allow from all
Order allow,deny
MonoSetServerAlias mydomaincom
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>
I was able to resolve this by simply adding MonoSetEnv MONO_IOMAP=all to my httpd.conf configuration file (usually located at /etc/apache2/httpd.conf).
MonoSetEnv MONO_IOMAP=all