LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-04-2011, 11:11 PM   #1
decenter
Member
 
Registered: Sep 2011
Distribution: Fedora release 21 (Twenty One)
Posts: 156

Rep: Reputation: 19
How to force ssl?


Hello,

I have tried the .htaccess method of forcing ssl. But it never works on my server. I have modrewrite loaded. Any other solution? I need to force the full site to ssl.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-04-2011, 11:22 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
You can require SSL with the (appropriately named) directive:
Code:
SSLRequireSSL
That's different than redirecting / rewriting requests from one TCP port to another, though. Any container with the above directive will barf out an HTTP 403 if a non-SSL client attempts to access it.

BTW, I'm assuming you're talking Apache web server? Version 2.2? (That's good info to include in your question.)
 
Old 09-04-2011, 11:46 PM   #3
decenter
Member
 
Registered: Sep 2011
Distribution: Fedora release 21 (Twenty One)
Posts: 156

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by anomie View Post
You can require SSL with the (appropriately named) directive:
Code:
SSLRequireSSL
That's different than redirecting / rewriting requests from one TCP port to another, though. Any container with the above directive will barf out an HTTP 403 if a non-SSL client attempts to access it.

BTW, I'm assuming you're talking Apache web server? Version 2.2? (That's good info to include in your question.)

yea. It is apache 2.2. Sorry for not giving enough details. But if we use SSLRequireSSL , it will give error page if some one access the http. But, I just need to force ssl.
 
Old 09-05-2011, 12:38 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Setup a redirect to https://your.site.tld with mod_rewrite. There are a bunch of examples on the net for this.
 
Old 09-05-2011, 02:03 AM   #5
decenter
Member
 
Registered: Sep 2011
Distribution: Fedora release 21 (Twenty One)
Posts: 156

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by zhjim View Post
Setup a redirect to https://your.site.tld with mod_rewrite. There are a bunch of examples on the net for this.
It goes to infinite redirect loops.
 
Old 09-05-2011, 02:22 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,159
Blog Entries: 1

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Hi,

Use mod_rewrite:
Code:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
Also make sure that you have
Code:
AllowOverride All
so apache reads the .htaccess file.

Regards
 
2 members found this post helpful.
Old 09-05-2011, 08:53 AM   #7
decenter
Member
 
Registered: Sep 2011
Distribution: Fedora release 21 (Twenty One)
Posts: 156

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by bathory View Post
Hi,

Use mod_rewrite:
Code:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
Also make sure that you have
Code:
AllowOverride All
so apache reads the .htaccess file.

Regards
Thanks. That worked
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub Folders in Apache Force SSL? carlosinfl Linux - Server 3 01-28-2011 04:21 PM
Force SSL on Web Folders [APACHE] carlosinfl Linux - Server 4 09-30-2010 09:18 AM
how to force yes-response ssl prompting lynx fancylad Linux - General 5 10-24-2008 04:35 PM
Force SSL on Apache - Slackware 11 stormtracknole Slackware 3 11-28-2006 02:10 AM
Force ssl in squirrelmail sbabcock23 Linux - Server 3 08-23-2006 08:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration