This is probably an Apache ABC but I do not see the light.
I want to my Django admin pages served in https, but only the admin pages. This implies:
- Redirect
http://my_site/admin/*
to https://my_site/admin/*
.
- Redirect all traffic that is https but not part of https://my_site/admin back to http.
After googling I created the following apache rewrite rules
RewriteCond %{HTTPS} off
RewriteRule ^/?(admin.*) https://%{SERVER_NAME}/$1 [R, L]
RewriteCond %{HTTPS} on
RewriteRule !^/?(admin.*) http://%{SERVER_NAME}/$1 [R, L]
Result: Going to http://my_site/admin redirects to https://my_site/admin (hurray) and the browser gives message Error code: ERR_TOO_MANY_REDIRECTS, this webpage has a redirect loop.
Does anybody have a hint where I am wrong?
Below the full httpd.conf (made anonymous)
Thanks in advance, Arjan.
ServerRoot "/home/my_account/webapps/my_app/apache2"
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
RewriteEngine On
RewriteLog "/home/my_account/logs/user/rewrite.log"
RewriteCond %{HTTPS} off
RewriteRule ^/?(admin.*) https://%{SERVER_NAME}/$1 [R, L]
RewriteCond %{HTTPS} on
RewriteRule !/?(admin.*) http://%{SERVER_NAME}/$1 [R, L]
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/my_account/logs/user/access_my_account.log
ErrorLog /home/my_account/logs/user/error_my_account.log
KeepAlive Off
Listen 24047
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5
WSGIDaemonProcess my_app processes=2 threads=12 python-path=/home/my_account/webapps/my_app:/home/my_account/webapps/my_app/my_app_folder:/home/my_account/webapps/my_app/lib/python2.7:/home/my_account/webapps/my_app/lib/python2.7/site-packages
WSGIProcessGroup my_app
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIScriptAlias / /home/my_account/webapps/my_app/my_app_folder/my_app_folder/wsgi.py
asked
06 Jan '14, 14:53
ArjandeK
1●1●1
accept rate:
0%