da http:// a https:// dopo essersi logati

10 contenuti / 0 new
Ultimo contenuto
da http:// a https:// dopo essersi logati

Salve a tutti, desidero porvi questa domanda :
sul server netsons si ha la possibilità di avere un indirizzo https://nome sito..., la domanda è :
come fare per passare o indirizzare una volta entrato come utente da un indirizzo :

http://nome sito ad https:// nomesito ?
in poche parole, usare la conessione sicura solo da utente registrato, una volta uscito torno alla pagina normale cioè http://
perdonatemi, non so se mi sono spiegato bene,
Grazie

Ciao sklaxdix,

stavo giusto cercando di fare la stessa identica cosa... e ci sono vicino ma non riesco a fare l'ultimo passo.
Ti spiego dove sono arrivato e spero che altri possano aiutarci a portare a termine.

Eccoti il virtual host che gestisce il mio sito:

<VirtualHost 127.0.1.1:80>
        ServerAdmin [email protected]
        ServerName saturno.elabor.net
        DocumentRoot "/var/www/drupal"
        <Directory "/var/www/drupal">
                AllowOverride All
        </Directory>
        RewriteEngine On
        RewriteCond %{REQUEST_URI} ^/user/
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost 127.0.1.1:443>
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
        ServerAdmin [email protected]
        ServerName saturno.elabor.net
        DocumentRoot "/var/www/drupal"
        <Directory "/var/www/drupal">
                AllowOverride All
        </Directory>
        RewriteEngine on
        #RewriteCond %{REQUEST_URI} !^/user(.*)
        RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

In questo modo, data le rewrite rule dell'host in chiaro, quando accedo ad una URI che inizia per /user (URI dal quale devo passare per autenticarmi) vengo rediretto verso https. Fin qui tutto ok.

Ora, quello che voglio è che quando abbandono la /user devo tornare in chiaro.
Per far questo avevo messo, nell'host sicuro, la rewrite condition:

RewriteCond %{REQUEST_URI} !^/user(.*)

(che sopra ho commentato)
In effetti ora quando accedo ad un'altra URI, tipo https://saturno.elabor.net/contacts, da https vengo riportato su http.

Quello che però non funziona più è che se chiedo:

http://saturno.elabor.net/user

non vengo più rediretto su https bensì su:

http://saturno.elabor.net/index.php?q=user/

Non so più dove sbattere la testa... qualche idea?

"E in un attimo ma come accade spesso, cambiò il volto di ogni cosa..." (F. Guccini)

<VirtualHost 127.0.1.1:80>
        ServerAdmin [email protected]
        ServerName saturno.elabor.net
        DocumentRoot "/var/www/drupal"
        <Directory "/var/www/drupal">
                AllowOverride All
        </Directory>
        RewriteEngine On
        RewriteCond %{REQUEST_URI} ^/user
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost 127.0.1.1:443>
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
        ServerAdmin [email protected]
        ServerName saturno.elabor.net
        DocumentRoot "/var/www/drupal"
        <Directory "/var/www/drupal">
                AllowOverride All
        </Directory>
        RewriteEngine on
        RewriteCond %{REQUEST_URI} !^/user(.*)
        RewriteCond %{QUERY_STRING} !^q=user
        RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

and it works!!!!

Devo farti i complimenti,d'avvero bravo !
Ora sono io che non riesco a starti dietro, per essere più preciso :
In quale file devo fare la modifica modificare ?
Grazie di nuovo

Ciao,

dunque, le configurazioni che ho scritto sopra sono a puro titolo di esempio e sarebbero due virtual host da mettere in un file a parte dentro /etc/apache2/site-available.

Probabilmente ti conviene dare un'occhio a questo breve how-to per come gestire in generale i virtual host:

http://www.e-pillole.com/linux/post/71/gestione-moduli-e-virtual-hosts-d...

L'alternativa è integrare solo le regole di Rewrite (ma vanno modificate) dentro il file .htaccess dell'installazione di drupal.

eradan wrote:

L'alternativa è integrare solo le regole di Rewrite (ma vanno modificate) dentro il file .htaccess dell'installazione di drupal.

Ciao, credo sia meglio partire da qua !
quindi devo modificare il file .htaccess prima dell'installazione oppure anche su di un sito già funzionante ?
Prendiamo per esempio netsosns cosa modificare:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/user/
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

----------------------------------------
RewriteEngine on
#RewriteCond %{REQUEST_URI} !^/user(.*)
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

Grazie

Ciao,

ti invio quella che mi sembra la soluzione al tuo caso però ti avverto per onestà che non ho avuto il tempo di provarla. Ecco quello che penso tu debba aggiungere al tuo .htaccess

# il certificato con il quale cifrare la connessione
SSLEngine on
SSLCertificateFile /path/to/your/cerificate.pem
SSLCertificateKeyFile /path/to/your/key.key
# abilito la rewrite engine
RewriteEngine on
# regola1: voglio una connessione cifrata quando chiedo la risorsa /user
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/user
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# regola 2: voglio tornare in chiaro quando abbandono /user
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/user(.*)
RewriteCond %{QUERY_STRING} !^q=user
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

Scusami, ma non ci riesco, ti allego il mio htaccess così che tu possa inserire le modifiche
per poter capire meglio Grazie.
-------------------
#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.

Order allow,deny

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# PHP 4, Apache 2.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# PHP 5, Apache 1 and 2.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# Requires mod_expires to be enabled.

# Enable expirations.
ExpiresActive On

# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600

# Do not cache dynamically generated pages.
ExpiresByType text/html A1

# Various rewrite rules.

RewriteEngine on

# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /

# Rewrite URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.90 2007/10/05 14:43:23 dries Exp $

Qualcuno ha provato se funziona ?

Salve, vorrei riprendere la discussione in merito al problema in oggetto.
A breve devo registrare e costruire un sito per il gruppo volontari della protezione civile del mio comune.
Ho pensato che http://www.dnshosting.it/dnshst/hosting-drupal.jsp sia un buon compromesso e con la sua ssl condivisa mi permette di avere un'area dedicata con una maggior sicurezza, almeno virtuale. Cosa ne pensate ?

Per rinfrescarmi un pochino le idee, dove inserire il certificato o ??

L'obiettivo è sempre lo stesso quando un utente richiama la pagina per registrarsi deve passare dal HTTP/ la HTTPS/ una volta uscito deve tornare in HTTP/
Grazie anticipatamente
Skla