Apache config for sending only username/password via https/ssl

Author Message

Jonny Bergkvist

Monday 27 October 2003 12:19:29 pm

I have a eZ 3.2-site on Debian with Apache and Apache-SSL (not mod-ssl):

I have achieved to send all username/password in https (encrypted), and everything else goes in http (clear-text).

In apache/http it does a rewrite to https if you request a url-path that begins with /user.

And in apache-ssl/https it does a rewrite to http if you request another url-path than /user.

From /etc/apache/httpd.conf:
<VirtualHost *>
<Directory /ezroot>
Options FollowSymLinks Indexes ExecCGI
AllowOverride None
Order deny,allow
allow from all
</Directory>

ServerAdmin webmaster@hostname.com
ServerName hostname.domain.com
ServerAlias admin.hostname.domain.com
DocumentRoot /ezroot/

RewriteEngine On
RewriteRule ^/user(.*)$ https://%{HTTP_HOST}/user$1 [L]
RewriteRule !\.(gif|css|jpg|png|jar|ico|js)$ /ezroot/index.php
</VirtualHost>


From /etc/apache-ssl/httpd.conf:
<VirtualHost *>
<Directory /ezroot>
Options FollowSymLinks Indexes ExecCGI
AllowOverride None
Order deny,allow
allow from all
</Directory>

ServerAdmin webmaster@domain.com
ServerName hostname.domain.com
ServerAlias admin.hostname.domain.com
DocumentRoot /ezroot/

SSLCACertificatePath /etc/apache-ssl/cert
SSLCACertificateFile /etc/apache-ssl/cert/ca.txt
SSLCertificateFile /etc/apache-ssl/cert/certificate.crt
SSLCertificateKeyFile /etc/apache-ssl/cert/private.key

RewriteEngine On
RewriteRule ^/user(.*)$ /ezroot/index.php [L]
RewriteRule ^(.*) http://%{HTTP_HOST}$1 [L]
</VirtualHost>

The only problem I have found with this config is that if you are not authenticated and open url: http://admin.hostname.domain.com/ then you are presented the login-page without the /user/login appended in the url-path. I think I must hack some of the php-code to append the /user/login to the url in order to get redirected to https...?

Except for that is seems to work fine. Please give me feedback about this config :-)

Regards, Jonny

Jonny Bergkvist

Tuesday 28 October 2003 4:34:52 am

I just found a solution that works for the http://admin.hostname.domain.com/ when not autenticated:

I repeat the rewrite-stuff including the new entries:

/etc/apache/htttp.conf:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^admin\.hostname\.domain\.com [NC]
RewriteRule ^/$ https://%{HTTP_HOST} [L]

RewriteRule ^/user(.*)$ https://%{HTTP_HOST}/user$1 [L]
RewriteRule !\.(gif|css|jpg|png|jar|ico|js)$ /ezroot/index.php

/etc/apache-ssl/httpd.conf:
RewriteEngine On
RewriteRule ^/user(.*)$ /ezroot/index.php [L]
RewriteRule ^/$ /ezroot/index.php [L]
RewriteRule \.(gif|css|jpg|png|jar|ico|js)$ %{REQUEST_URI} [S=1]
RewriteRule ^(.*) http://%{HTTP_HOST}$1 [L]

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 04:24:10
Script start
Timing: Jan 19 2025 04:24:10
Module start 'layout'
Timing: Jan 19 2025 04:24:10
Module start 'content'
Timing: Jan 19 2025 04:24:10
Module end 'content'
Timing: Jan 19 2025 04:24:10
Script end

Main resources:

Total runtime0.7597 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.4141152.6563
Module start 'layout' 0.00580.0032 742.070339.5234
Module start 'content' 0.00900.7493 781.5938479.3047
Module end 'content' 0.75830.0014 1,260.898412.0938
Script end 0.7597  1,272.9922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4958160.0002
Check MTime0.00160.2107160.0001
Mysql Total
Database connection0.00070.095810.0007
Mysqli_queries0.702292.4328520.0135
Looping result0.00050.0608500.0000
Template Total0.727095.720.3635
Template load0.00210.276820.0011
Template processing0.724995.419320.3625
Template load and register function0.00010.013010.0001
states
state_id_array0.00110.142010.0011
state_identifier_array0.00070.094520.0004
Override
Cache load0.00180.2381640.0000
Sytem overhead
Fetch class attribute can translate value0.00050.061310.0005
Fetch class attribute name0.00130.165330.0004
XML
Image XML parsing0.00160.209210.0016
class_abstraction
Instantiating content class attribute0.00000.001240.0000
General
dbfile0.00190.2554160.0001
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs