Apache 2.4 LogLevel and rewrite is ignored - apache

I'm trying to understand why my attempt at logging redirects and rewrites are failing in my config. I've added "LogLevel debug rewrite:trace6" to my virtual domain config and it isn't reflected in the error_log shown below.
I'm also having a problem with redirects. Can I log them in the same way to find out why they're seemingly being ignored?
I would like to redirect all requests for https://example.com/download.html to instead go to https://example.com/resource-center and only the third one below works. However, I want to be sure only /download.html off the root works, not /folder/download.html. How can I do this?
Redirect 301 ^/download.html /resource-center
Redirect 301 ^download.html /resource-center
Redirect 301 /download.html /resource-center
These redirects appear in the Include file with my config.
I've included the entirety of my config here, as I'm not sure which parts are needed to help troubleshoot this.
This is httpd-2.4.43-1.fc32.x86_64 on fedora32.
ServerTokens Prod
ServerSignature Off
<VirtualHost 222.111.222.111:443>
ServerName example.com
ServerAlias example.com engage.example.com www.example.com support.example.com infocenter.example.com store.example.com updates.example.com
ServerAdmin gdadmin#example.com
DocumentRoot /var/www/www.example.com-443/html/
ScriptAlias /cgi-bin/ /var/www/www.example.com-443/cgi-bin/
ErrorLog /var/www/www.example.com-443/logs/error_log
CustomLog /var/www/www.example.com-443/logs/access_log timing
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %T/%D %I/%O/%B H:%H U:%U gd443 s:%s V:%V v:%v" timing
CustomLog "/var/www/www.example.com-443/logs/cached-requests.log" timing env=cache-hit
CustomLog "/var/www/www.example.com-443/logs/uncached-requests.log" timing env=cache-miss
CustomLog "/var/www/www.example.com-443/logs/revalidated-requests.log" timing env=cache-revalidate
CustomLog "/var/www/www.example.com-443/logs/invalidated-requests.log" timing env=cache-invalidate
LogLevel debug rewrite:trace6
LogLevel error ssl:warn
SuexecUserGroup guardian guardian
HostnameLookups off
RewriteEngine on
RewriteCond %{HTTP_HOST} ^infocenter.example.com$
RewriteRule ^ https://example.com/cloud-email-security? [L,R=301]
RewriteCond %{HTTP_HOST} ^store\.example\.com$
RewriteRule ^ https://example.com/cloud-email-security? [L,R=301]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{QUERY_STRING} ^list=
RewriteRule /eng/ https://example.com/? [R=301,L]
RewriteRule /advisories/ https://example.com/? [R=301,L]
KeepAliveTimeout 120
Timeout 120
ProxyTimeout 120
<IfModule mod_log_config.c>
CustomLog "|/var/www/html/apache_pipelogger" "%v %p %m %B %D %s"
</IfModule>
SecStatusEngine On
<IfModule !mod_php5.c>
<IfModule !mod_php7.c>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:/run/php-fpm/example.sock|fcgi://localhost"
</FilesMatch>
</IfModule>
</IfModule>
<Directory "/var/www/www.example.com-443/html">
AllowOverride all
Options +FollowSymLinks +Includes +ExecCGI
DirectoryIndex index.html index.php
Include /etc/httpd/conf.d/example-old-links.htaccess
</Directory>
SSLEngine on
Header always set Strict-Transport-Security "max-age=15768000"
Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
Header always set X-FRAME-OPTIONS "SAMEORIGIN"
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options "nosniff"
SSLCertificateKeyFile /etc/letsencrypt/privkey.pem
SSLCertificateFile /etc/letsencrypt/cert.pem
SSLCertificateChainFile /etc/letsencrypt/fullchain.pem
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/plain text/xml application/javascript
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
</IfModule>
</IfModule>
Header append Vary User-Agent env=!dont-vary
</VirtualHost>
<VirtualHost 222.111.222.111:80>
ServerName example.com
ServerAlias example.com engage.example.com www.example.com support.example.com infocenter.example.com store.example.com updates.example.com
ServerAdmin gdadmin#example.com
ErrorLog /var/www/www.example.com-443/logs/error_log
CustomLog /var/www/www.example.com-443/logs/access_log timing
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %T/%D %I/%O/%B H:%H U:%U gd80 s:%s V:%V v:%v" timing
</VirtualHost>
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
SSLHonorCipherOrder on
SSLCompression off
SSLSessionTickets off
SSLUseStapling on
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors off
SSLStaplingCache shmcb:/var/run/ocsp(128000)

There are two LogLevel directives in your config
LogLevel debug rewrite:trace6
LogLevel error ssl:warn
and the second one overrides the first one. Comment the second directive when debugging.
The redirect
Redirect 301 /download.html /resource-center
looks fine to me, the other two won't work as expected since Redirect
doesn't work with regexes as URL path (but RedirectMatch does).
It's also a feature of mod_alias and not of mod_rewrite if you're wondering why these requests are not logged with rewrite:trace6.
You could use a RewriteRule instead if you want to use mod_rewrite, e.g.
RewriteRule ^/download\.html$ /resource-center [R=301,L]

Related

Apache ServerAlias seems not working in ubuntu

I am trying to create multiple serveralias in apache2.4.25. It works but one of the serveralias sometimes shows 403 fobidden error. Here's my apache virtual config.
<VirtualHost *:80>
ServerName sajhamanch.com
ServerAlias www.sajhamanch.com
ServerAlias english.sajhamanch.com
ServerAlias webmail.sajhamanch.com
ServerAlias autoconfig.sajhamanch.com
ServerAlias autodiscover.sajhamanch.com
DocumentRoot /home/sajhamanch/public_html
ErrorLog /var/log/virtualmin/sajhamanch.com_error_log
CustomLog /var/log/virtualmin/sajhamanch.com_access_log combined
ScriptAlias /cgi-bin/ /home/sajhamanch/cgi-bin/
ScriptAlias /AutoDiscover/AutoDiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /Autodiscover/Autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /autodiscover/autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/sajhamanch/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddType application/x-httpd-php7.0 .php7.0
</Directory>
<Directory /home/sajhamanch/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.sajhamanch.com
RewriteRule ^(.*) https://host.crystalsoft.com.np:20000 [R]
<LocationMatch "^(.*\.php)$">
ProxyPass fcgi://127.0.0.1:9002/home/sajhamanch/public_html
</LocationMatch>
Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
Redirect /.well-known/autoconfig/mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
</VirtualHost>
<VirtualHost 139.59.22.58:443>
ServerName sajhamanch.com
ServerAlias www.sajhamanch.com
ServerAlias english.sajhamanch.com
ServerAlias webmail.sajhamanch.com
ServerAlias autoconfig.sajhamanch.com
ServerAlias autodiscover.sajhamanch.com
DocumentRoot /home/sajhamanch/public_html
ErrorLog /var/log/virtualmin/sajhamanch.com_error_log
CustomLog /var/log/virtualmin/sajhamanch.com_access_log combined
ScriptAlias /cgi-bin/ /home/sajhamanch/cgi-bin/
ScriptAlias /AutoDiscover/AutoDiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /Autodiscover/Autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
ScriptAlias /autodiscover/autodiscover.xml /home/sajhamanch/cgi-bin/autoconfig.cgi
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/sajhamanch/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddType application/x-httpd-php7.0 .php7.0
</Directory>
<Directory /home/sajhamanch/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.sajhamanch.com
RewriteRule ^(.*) https://host.crystalsoft.com.np:20000 [R]
SSLEngine on
SSLCertificateFile /home/sajhamanch/ssl.cert
SSLCertificateKeyFile /home/sajhamanch/ssl.key
SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2
####### http2 #########
Protocols h2 http/1.1
######## php fpm link #############
<LocationMatch "^(.*\.php)$">
ProxyPass fcgi://127.0.0.1:9002/home/sajhamanch/public_html
</LocationMatch>
SSLCACertificateFile /home/sajhamanch/ssl.ca
Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
Redirect /.well-known/autoconfig/mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
</VirtualHost>
Here's my .htacess
ExpiresActive On
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/bmp "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/html "access plus 0 seconds"
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/javascript application/x-javascript
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "public,max-age=25920000"
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.sajhamanch\.com
RewriteRule ^(.*)$ https://www.sajhamanch.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^english\.sajhamanch\.com
RewriteRule ^(.*)$ https://english.sajhamanch.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^sajhamanch\.com
RewriteRule ^(.*)$ https://www.sajhamanch.com/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
But when I visit to https://english.sajhamanch.com, apache sometimes shows me 403 error page.
No Problem in DNS Config. And I also have these meta tags in all pages
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
What could be the problem?

Is it possible to set ErrorDocument in Apache httpd for defined alias?

Background:
I have an apache configuration file on my webserver and it has a route address and then a number of alias' defined. The issue i have is that in the event of a 404 the user is re-directed to the root site even when using the alias portal, which looking at the configuration file makes sense.
Question
How can i define the ErrorDocument settings for each of my aliases?
Source Code
<VirtualHost *:80>
ServerAlias *.samplesite.mysite.mycompany.co.uk
UseCanonicalName Off
ErrorDocument 404 /404.html
DocumentRoot /var/www/html/mysite1
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript text/javascript application/json
Alias /mysite2 /var/www/html/mysite2
Alias /mysite3 /var/www/html/mysite3
Alias /mysite4 /var/www/html/mysite4
<Directory "/var/www/html/mysite1">
Require all granted
Options +Indexes
</Directory>
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/mysite_access_log vcommon
LogLevel info
#LogLevel debug rewrite:trace6
ErrorLog "logs/mysite-error.log"
</VirtualHost>
ok so i found the answer, will post just incase its useful to anyone else:
Alias /mysite2 /var/www/html/mysite2
<Directory "/var/www/html/mysite2">
ErrorDocument 404 /mysite2/404.html
Require all granted
Options +Indexes
</Directory>
Alias /mysite3 /var/www/html/mysite3
<Directory "/var/www/html/mysite3">
ErrorDocument 404 /mysite3/404.html
Require all granted
Options +Indexes
</Directory>
Alias /mysite4 /var/www/html/mysite4
<Directory "/var/www/html/mysite4">
ErrorDocument 404 /mysite4/404.html
Require all granted
Options +Indexes
</Directory>

Plesk WWW prefix

I'm having trouble with the WWW prefix for my domain. Whenever I goto the domain http://mydomain.com I get the correct index page. However, using the www prefix, I get the plesk default index page.
I have a subdomain called *.mydomain.com that points to it's parent httpdocs directory which is required for a url rewrite to our salespeople's profile pages (see below). There is also an alias for a completely different domain for mydomain.com (as you will see in last_httpd.include)
I can't seem to narrow it down. Commenting out the url rewrites in .htaccess didn't seem to work, neither did removing the *.mydomain.com subdomain.
I've provided what I can to perhaps give some insight to how things are setup. Thanks in advance for the help.
The www record in DNS is set as an A(host) record.
Here is the contents of my .htaccess file for the main domain. The domain name edited for obvious reasons...
#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript
</ifmodule>
#End Gzip
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain.com
RewriteCond %{HTTP_HOST} ^(.+).mydomain.com
RewriteRule ^(.*)$ http://mydomain.com/agents/agent.php?agent=%1 [P,L]
My last_http.include file for the main domain in /var/vhosts/www/mydomain.com/conf/
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
#
#IF YOU REQUIRE TO APPLY CUSTOM MODIFICATIONS, PERFORM THEM IN THE FOLLOWING FILES:
#/var/www/vhosts/mydomain.com/conf/vhost.conf
#/var/www/vhosts/mydomain.com/conf/vhost_ssl.conf
<IfModule mod_ssl.c>
<VirtualHost 10.10.10.10:443 >
ServerName "mydomain.com"
ServerAlias "www.mydomain.com"
ServerAlias "ipv4.mydomain.com"
UseCanonicalName Off
ServerAlias "mydomainalias.com"
ServerAlias "www.mydomainalias.com"
ServerAlias "ipv4.mydomainalias.com"
<IfModule mod_suexec.c>
SuexecUserGroup "mydomain" "psacln"
</IfModule>
ServerAdmin "admin#mydomain.com"
DocumentRoot "/var/www/vhosts/mydomain.com/httpdocs"
CustomLog /var/www/vhosts/mydomain.com/statistics/logs/access_ssl_log plesklog
ErrorLog "/var/www/vhosts/mydomain.com/statistics/logs/error_log"
<IfModule mod_userdir.c>
UserDir "/var/www/vhosts/mydomain.com/web_users"
</IfModule>
ScriptAlias "/cgi-bin/" "/var/www/vhosts/mydomain.com/cgi-bin/"
Alias "/plesk-stat" "/var/www/vhosts/mydomain.com/statistics"
<Location /plesk-stat/>
Options +Indexes
</Location>
<Location /plesk-stat/logs/>
Require valid-user
</Location>
Alias /webstat /var/www/vhosts/mydomain.com/statistics/webstat
Alias /webstat-ssl /var/www/vhosts/mydomain.com/statistics/webstat-ssl
Alias /ftpstat /var/www/vhosts/mydomain.com/statistics/ftpstat
Alias /anon_ftpstat /var/www/vhosts/mydomain.com/statistics/anon_ftpstat
Alias /awstats-icon /var/www/html/awstats/icon
SSLEngine on
SSLVerifyClient none
SSLCertificateFile /usr/local/psa/var/certificates/certQ69DPXb
SetEnv PP_CUSTOM_PHP_INI /var/www/vhosts/mydomain.com/etc/php.ini
<IfModule mod_fcgid.c>
FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/mydomain.com/etc/php.ini
FcgidMaxRequestLen 16777216
</IfModule>
<Directory /var/www/vhosts/mydomain.com/httpdocs>
<IfModule mod_perl.c>
<Files ~ (\.pl$)>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Files>
</IfModule>
<IfModule sapi_apache2.c>
php_admin_flag engine on
# General settings
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/mydomain.com/:/tmp/"
php_admin_flag display_errors off
php_admin_flag log_errors on
php_admin_flag magic_quotes_gpc off
# Performance settings
php_admin_value memory_limit 64M
php_admin_value upload_max_filesize 256M
# Additional directives
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
# General settings
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/mydomain.com/:/tmp/"
php_admin_flag display_errors off
php_admin_flag log_errors on
php_admin_flag magic_quotes_gpc off
# Performance settings
php_admin_value memory_limit 64M
php_admin_value upload_max_filesize 256M
# Additional directives
</IfModule>
<IfModule mod_python.c>
<Files ~ (\.py$)>
SetHandler python-program
PythonHandler mod_python.cgihandler
</Files>
</IfModule>
<IfModule mod_fcgid.c>
<Files ~ (\.fcgi)>
SetHandler fcgid-script
Options +FollowSymLinks +ExecCGI
</Files>
</IfModule>
SSLRequireSSL
Options -Includes +ExecCGI
</Directory>
<Directory "/var/www/vhosts/mydomain.com/statistics">
AuthType Basic
AuthName "Domain statistics"
AuthUserFile "/var/www/vhosts/mydomain.com/pd/d..httpdocs#plesk-stat"
require valid-user
</Directory>
Alias /error_docs /var/www/vhosts/mydomain.com/error_docs
ErrorDocument 400 /error_docs/bad_request.html
ErrorDocument 401 /error_docs/unauthorized.html
ErrorDocument 403 /error_docs/forbidden.html
ErrorDocument 404 /error_docs/not_found.html
ErrorDocument 500 /error_docs/internal_server_error.html
ErrorDocument 405 /error_docs/method_not_allowed.html
ErrorDocument 406 /error_docs/not_acceptable.html
ErrorDocument 407 /error_docs/proxy_authentication_required.html
ErrorDocument 412 /error_docs/precondition_failed.html
ErrorDocument 414 /error_docs/request_uri_too_long.html
ErrorDocument 415 /error_docs/unsupported_media_type.html
ErrorDocument 501 /error_docs/not_implemented.html
ErrorDocument 502 /error_docs/bad_gateway.html
ErrorDocument 503 /error_docs/maintenance.html
Include "/usr/local/psa/admin/conf/file_sharing.conf*"
</VirtualHost>
</IfModule>
<VirtualHost 10.10.10.10:80 >
ServerName "mydomain.com"
ServerAlias "www.mydomain.com"
ServerAlias "ipv4.mydomain.com"
UseCanonicalName Off
ServerAlias "mydomainalias.com"
ServerAlias "www.mydomainalias.com"
ServerAlias "ipv4.mydomainalias.com"
<IfModule mod_suexec.c>
SuexecUserGroup "mydomain" "psacln"
</IfModule>
ServerAdmin "admin#mydomain.com"
DocumentRoot "/var/www/vhosts/mydomain.com/httpdocs"
CustomLog /var/www/vhosts/mydomain.com/statistics/logs/access_log plesklog
ErrorLog "/var/www/vhosts/mydomain.com/statistics/logs/error_log"
<IfModule mod_userdir.c>
UserDir "/var/www/vhosts/mydomain.com/web_users"
</IfModule>
ScriptAlias "/cgi-bin/" "/var/www/vhosts/mydomain.com/cgi-bin/"
Redirect permanent /plesk-stat https://mydomain.com/plesk-stat
Redirect permanent /webstat https://mydomain.com/webstat
Redirect permanent /webstat-ssl https://mydomain.com/webstat-ssl
Redirect permanent /ftpstat https://mydomain.com/ftpstat
Redirect permanent /anon_ftpstat https://mydomain.com/anon_ftpstat
Redirect permanent /awstats-icon https://mydomain.com/awstats-icon
<IfModule mod_ssl.c>
SSLEngine off
</IfModule>
SetEnv PP_CUSTOM_PHP_INI /var/www/vhosts/mydomain.com/etc/php.ini
<IfModule mod_fcgid.c>
FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/mydomain.com/etc/php.ini
FcgidMaxRequestLen 16777216
</IfModule>
<Directory /var/www/vhosts/mydomain.com/httpdocs>
<IfModule mod_perl.c>
<Files ~ (\.pl$)>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Files>
</IfModule>
<IfModule sapi_apache2.c>
php_admin_flag engine on
# General settings
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/mydomain.com/:/tmp/"
php_admin_flag display_errors off
php_admin_flag log_errors on
php_admin_flag magic_quotes_gpc off
# Performance settings
php_admin_value memory_limit 64M
php_admin_value upload_max_filesize 256M
# Additional directives
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
# General settings
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/mydomain.com/:/tmp/"
php_admin_flag display_errors off
php_admin_flag log_errors on
php_admin_flag magic_quotes_gpc off
# Performance settings
php_admin_value memory_limit 64M
php_admin_value upload_max_filesize 256M
# Additional directives
</IfModule>
<IfModule mod_python.c>
<Files ~ (\.py$)>
SetHandler python-program
PythonHandler mod_python.cgihandler
</Files>
</IfModule>
<IfModule mod_fcgid.c>
<Files ~ (\.fcgi)>
SetHandler fcgid-script
Options +FollowSymLinks +ExecCGI
</Files>
</IfModule>
Options -Includes +ExecCGI
</Directory>
<Directory "/var/www/vhosts/mydomain.com/statistics">
AuthType Basic
AuthName "Domain statistics"
AuthUserFile "/var/www/vhosts/mydomain.com/pd/d..httpdocs#plesk-stat"
require valid-user
</Directory>
Alias /error_docs /var/www/vhosts/mydomain.com/error_docs
ErrorDocument 400 /error_docs/bad_request.html
ErrorDocument 401 /error_docs/unauthorized.html
ErrorDocument 403 /error_docs/forbidden.html
ErrorDocument 404 /error_docs/not_found.html
ErrorDocument 500 /error_docs/internal_server_error.html
ErrorDocument 405 /error_docs/method_not_allowed.html
ErrorDocument 406 /error_docs/not_acceptable.html
ErrorDocument 407 /error_docs/proxy_authentication_required.html
ErrorDocument 412 /error_docs/precondition_failed.html
ErrorDocument 414 /error_docs/request_uri_too_long.html
ErrorDocument 415 /error_docs/unsupported_media_type.html
ErrorDocument 501 /error_docs/not_implemented.html
ErrorDocument 502 /error_docs/bad_gateway.html
ErrorDocument 503 /error_docs/maintenance.html
Include "/usr/local/psa/admin/conf/file_sharing.conf*"
</VirtualHost>
What is the http code response from server? You can check it in Firebug on "Net" tab.
Check that www.mydomain.com resolves to same IP as mydomain.com (nslookup www.mydomain.com)
check that apache's config is applied: apachectl -S / apache2ctl -S | grep www.mydomain.com

HTTPS images not caching

I'm having some problems with caching images on my web app. The images are cached after refreshing, but when I reopen the browser it's not cached anymore. I'm using HTTPS, but I'm not sure it's the problem. This is the response from the server:
Response Headers
Accept-Ranges: bytes
Cache-Control: public
Connection: close
Content-Length: 3711
Content-Type: image/png
Date: Mon, 21 May 2012 14:08:46 GMT
ETag: "446b5-e7f-4c0559b8c1c9f"
Expires: Wed, 20 Jun 2012 14:08:46 GMT
Last-Modified: Fri, 18 May 2012 20:43:41 GMT
Server: Apache/2.2.22 (Amazon)
And our httpd.conf
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
ServerName [REMOVED]
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName [REMOVED]
#Force image type
AddType image/png .png
AddType image/jpeg jpeg jpg jpe
AddType font/x-woff .woff
#Cache
ExpiresActive On
ExpiresDefault A0
<FilesMatch "\.(png|jpg|jpeg|gif)$">
ExpiresDefault "access plus 1 month"
Header set Cache-Control "public"
</FilesMatch>
#Logs
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
#SSL
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile [REMOVED]
SSLCertificateKeyFile [REMOVED]
SSLCertificateChainFile [REMOVED]
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
#Proxy
DocumentRoot [REMOVED]
ProxyPreserveHost On
ProxyRequests Off
ProxyPass [REMOVED] http://localhost:8081/[REMOVED]
ProxyPassReverse [REMOVED] http://localhost:8081/[REMOVED]
ProxyPassReverseCookiePath [REMOVED] /
Alias [REMOVED] [REMOVED]
</VirtualHost>
Any clue? Thanks!
The headers are fine. Cache-Control: public and future Expires should do the job.
It seems like it's the browser's decision not to store the cache permanently (that kind of paranoia about HTTPS data is typical), and I don't think you can do anything about that.

Apache: Deliver some urls from the file system, all others from Rails app

I want to host two different services on a Apache web server, reachable via the same domain: Some special URLs should go into the filesystem, all others should be handle by a Rails application.
Example:
http://mydomain.com/foo/123.txt
=> should deliver /var/www/special/foo/123.txt
http://mydomain.com/users
=> should go to Rails/Passenger
Here is my virtual host setup for the Rails app:
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias *.mydomain.com
DocumentRoot /var/www/mydomain/current/public
<Directory /var/www/mydomain/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
ExpiresActive on
ExpiresDefault "access plus 1 year"
FileETag MTime Size
</Directory>
RewriteEngine On
# Check for maintenance file and redirect all requests
ErrorDocument 503 /system/maintenance.html
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ - [redirect=503,last]
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/xml application/xhtml+xml text/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
ErrorLog /var/log/apache2/mydomain.com-error_log
CustomLog /var/log/apache2/mydomain.com-access_log combined
</VirtualHost>
Somewhere in the middle a RewriteCond/RewiteRule should be added, so accessing http://mydomain.com/foo/123.txt does not go to the Rails app, but the filesystem instead.
For this I need help. It would by great if someone can can give me a hint.
Found the solution by myself:
RewriteCond %{REQUEST_URI} ^/foo/.*$
RewriteRule ^.*$ /var/www/special/foo%{REQUEST_URI}