logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: HTTP to HTTPS and Vice Versa
Author
pawan1475



Joined: 13 Oct 2006
Posts: 2

PostPosted: Sat 14 Oct '06 8:35    Post subject: HTTP to HTTPS and Vice Versa Reply with quote

Hi, I know there have been some postings on the forums to do the HTTP to HTTPS and vice versa, but i tried but couldn't get it going for myself.

What i want is that if in the URL if there is a "secure" folder it should automatically use a HTTPS otherwise whould go back to HTTP
https://localhost/View/pages/secure/index.html ---> it has a "secure" folder in the URL
other wise it should just use normal http.

I have integrated Apache. mod_ssl, mod_jk with JBOSS /Tomcat on windows in the clustered environment. I just coouldn't get the mod_rewrite to work as i want.

Thanks in advance

Pawan Kharbanda

################ HTTPD.conf #############
Code:

ThreadsPerChild 250
MaxRequestsPerChild  0

ServerRoot "C:\apachewin_ssl"

Listen 80

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule jk_module modules/mod_jk.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule ssl_module modules/mod_ssl.so



ServerAdmin @@ServerAdmin@@
#ServerName localhost:80

DocumentRoot "C:\apachewin_ssl/htdocs"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Satisfy all
</Directory>

<Directory "C:\apachewin_ssl/htdocs">
    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny
    Allow from all

</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

ErrorLog logs/error.log
LogLevel debug

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog logs/access.log common

</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "C:\apachewin_ssl/cgi-bin/"

</IfModule>

<Directory "C:\apachewin_ssl/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>

# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include conf/mod-jk.conf


<VirtualHost _default_:80>

ServerName 10.88.106.144

RewriteLog logs/rewrite.log
RewriteLogLevel 9

RewriteEngine on
#RewriteRule /View/pages/secure/(.*)$ https://localhost/View/pages/secure/$1 [R,L]

RewriteEngine On
RewriteRule ^/secure/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>


############# httpd_ssl.conf #############

Code:

Listen 443

AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl

SSLPassPhraseDialog  builtin

SSLSessionCache        shmcb:C:\apachewin_ssl/logs/ssl_scache(512000)
SSLSessionCacheTimeout  300


SSLMutex default

                         
<VirtualHost _default_:443>

ServerName 10.88.106.144

ErrorLog C:\apachewin_ssl\logs/error_ssl_log
TransferLog C:\apachewin_ssl\logs/access_ssl_log

SSLEngine on

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile C:\apachewin_ssl\conf/ssl/server.crt
SSLCertificateKeyFile C:\apachewin_ssl\conf/ssl/server.key


BrowserMatch ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

CustomLog C:\apachewin_ssl/logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"


RewriteEngine on
RewriteCond %{REQUEST_URI} !^/secure/
RewriteRule ^/(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

</VirtualHost> 
         
Back to top
ked



Joined: 19 Apr 2006
Posts: 2
Location: Sweden

PostPosted: Sun 15 Oct '06 22:07    Post subject: Re: HTTP to HTTPS and Vice Versa Reply with quote

pawan1475 wrote:
Hi, I know there have been some postings on the forums to do the HTTP to HTTPS and vice versa, but i tried but couldn't get it going for myself.


The most elegant way of doing this IMHO is:

Code:
  RewriteEngine on
  RewriteCond   %{HTTPS}   off
  RewriteRule   (.*)      https://%{HTTP_HOST}%{REQUEST_URI}


inside a <directory> directive. To reverse it simply check for https->on and redirect to http.


Oops, I realize that I've delurked! Greetings peeps, and a heartfelt "Thanks m8!" to steffen for making the apache2 binaries and this micro-community public! Very Happy
Back to top


Reply to topic   Topic: HTTP to HTTPS and Vice Versa View previous topic :: View next topic
Post new topic   Forum Index -> Apache