How to user use shared ssl in drupal 7?

Comments

paulhudson’s picture

Sounds like a hosting setup issue to me. What issues do you have, you'll need to be more specific for people to help you.

chetan-singhal’s picture

Shared ssl in drupal

I found solution.

chetan

BrianLewisDesign’s picture

Here is the D7 setup that works for me on A2 shared hosting, with a shared certificate.

  1. /sites/default/settings.php - for the $base_url and $cookie_domain
  2. /.htaccess - https and remove www, because shared url can't have www
  3. pathologic module - do // protocol for the image paths
  4. securepages module - via shared https url, so you can turn it on
// (/sites/default/settings.php)
$request_is_ssl = (getenv('HTTPS') == '1' || getenv('HTTPS') == 'on' || !empty($_SERVER['HTTP_X_FORWARDED_HOST'])) ? TRUE : FALSE;
if ($request_is_ssl) {
  $base_url = 'https://mysite-wwwls7.ssl.supercp.com';
  $cookie_domain = '.mysite-wwwls7.ssl.supercp.com';  
  $_SERVER['HTTPS'] = 'on';  
  $conf = array('reverse_proxy' => TRUE, 'reverse_proxy_addresses' => array($_SERVER['REMOTE_ADDR']));
  //$_SERVER['REQUEST_URI'] = 'mysite-wwwls7.ssl.supercp.com' . $_SERVER['REQUEST_URI']; // Only the DNS name of the site needed here!
} else {  
  $base_url = 'http://mysite.com';  // NO trailing slash!
  $cookie_domain = '.mysite.com';
  $_SERVER['HTTPS'] = '';
}
# (/.htaccess)
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
/* pathologic module: (/admin/config/content/formats) > each text format > Correct URLs with Pathologic > Protocol relative URL http://mysite.com/ https://mysite-wwwls7.ssl.supercp.com/ (Save configuration) */
/* securepages module: (https://mysite-wwwls7.ssl.supercp.com/admin/config/system/securepages) > Enabled, Switch back to http pages when there are no matches, http://mysite.com, https://mysite-wwwls7.ssl.supercp.com, Make secure only the listed pages (Save configuration) */
redhatusr’s picture

I am trying to use shared ssl with drupal 7 and I have try on two hosting providers

$request_is_ssl = (getenv('HTTPS') == '1' || getenv('HTTPS') == 'on' || !empty($_SERVER['HTTP_X_FORWARDED_HOST'])) ? TRUE : FALSE;
if ($request_is_ssl) {
  $base_url = 'https://ams25.siteground.eu/~myuser/mydir';
  $cookie_domain = '.ams25.siteground.eu/~myuser/mydir';   
  $_SERVER['HTTPS'] = 'on';  
  $conf = array('reverse_proxy' => TRUE, 'reverse_proxy_addresses' => array($_SERVER['REMOTE_ADDR']));
} else {  
  $base_url = 'http://www.mydomain.com';
  $cookie_domain = '.www.mydomain.com';
  $_SERVER['HTTPS'] = '';
}

when I go to https://mydomain.com I get the warning messages, I download the certificate, and the browser show me the lock icon but instead of drupal I see a nginx message

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later. 

For the second hosting provider I change from the code above only the $base_url and $cookie_domain

<strong>$base_url</strong> = 'https://secure.hostmonster.com/~myuser/mydir';
<strong>$cookie_domain</strong> = '.secure.hostmonster.com/~myuser/mydir';

OR

<strong>$base_url</strong> = 'https://host202.hostmonster.com/~myuser/mydir';
<strong>$cookie_domain</strong> = '.host202.hostmonster.com/~myuser/mydir';

and when I go to https://mydomain.com it redirects me a provider message says "View temporary site" and then it redirects me to http://mydomain-com.myhostingregisterdomain.net

any ideas how to use the shared ssl?

greenbergmethew’s picture

1. Determine your shared SSL (as per the article above)
2. Once you know your Shared SSL URL, you will need to determine your Drupal installation directory as it applies to the shared SSL. For example: If your ssl path is username, and you installed your Drupal site in a folder called 'Drupal', then your path would be username/Drupal. If you installed your site to the default directory (public_html), then you would not need to change the shared SSL path - it would remain ~username.
3. Edit the settings.php file in your sites/default folder
4. Follow the directions to allow Drupal to use SSL
5. Add the following line (there should be an example of it in the file already): $base_url="~username/...)

redhatusr’s picture

After the providers support I get the right secure url and the site is working with https on
https://secureams25.sgcpanel.com/~myuser/mydir
so the settings.php has this code

$request_is_ssl = (getenv('HTTPS') == '1' || getenv('HTTPS') == 'on' || !empty($_SERVER['HTTP_X_FORWARDED_HOST'])) ? TRUE : FALSE;
if ($request_is_ssl) {
  $base_url = 'https://secureams25.sgcpanel.com/~myuser/mydir';
  $cookie_domain = '.secureams25.sgcpanel.com/~myuser/mydir';   
  $_SERVER['HTTPS'] = 'on';  
  $conf = array('reverse_proxy' => TRUE, 'reverse_proxy_addresses' => array($_SERVER['REMOTE_ADDR']));
} else {  
  $base_url = 'http://www.mydomain.com';
  $cookie_domain = '.www.mydomain.com';
  $_SERVER['HTTPS'] = '';
}

Adding this in .htaccess is needed to load the css
RewriteBase /~myuser/



but https on mydomain.com is still not working.
I have try many suggestions for .htaccess non of the are working

RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]

https not working - http working

# ALL EXCEPT SOME FILE EXTENSIONS TO "index.php" FILE.
#RewriteBase /~myuser
#RewriteCond %{SCRIPT_FILENAME} !-f
#RewriteCond %{SCRIPT_FILENAME} !-d
#RewriteRule .* index.php
# STRIP THE REWRITEBASE RULE FROM NON-SSL CONNECTIONS.
#RewriteCond %{SERVER_PORT} 80
#RewriteCond %{REQUEST_URI} ^/~myuser
#RewriteRule .* /index.php

https not working - http working

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]

https not working - http redirects to https

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

https not working - http redirects to https

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

https not working - http redirects to https


I am not sure but it seems this site needs a htaccess rule to make drupal working with https://secureams25.sgcpanel.com/~myuser/mydir but users only see https://mydomain.com

is it possible?

paulnevinthomas’s picture

If you really care about the data you are sending across the internet you want to make sure you are using SFTP instead of FTP, SSH instead of Telnet, and HTTPS instead of HTTP.

adammary’s picture

Using Prestashop 1.4.8.2 and am working on setting it up with Stripe for payment. Just want to be sure I have the steps correct before I go live.

Want to use the shared SSL for business class. Is the URL https://secure83.inmotionhosting.com/~userna5/mystore.com the URL which goes in Back Office - Preferences - SEO & URLs - Shop Domain name for SSL??

And, the next step Prestashop Dashboard - Preferences - General - Enable SSL - Save??

[webmaster edit: Please go light on the links to your company and services]

Or, have I got this backward?