LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-11-2010, 11:42 PM   #1
Arty Ziff
Member
 
Registered: May 2008
Location: Tacoma, WA
Distribution: CentOS and RHEL
Posts: 124

Rep: Reputation: 15
Problem with SSL


I'm having some problems with SSL.

In httpd.conf, I have these two directives:
Code:
<Directory "/home/my_site/public_html">
    AllowOverride All
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 443 
    RewriteRule ^(.*)$ http://www.my_site.com/$1 [R,L]
</Directory>

<Directory "/home/my_site/public_html/classes">
    AllowOverride All
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{REQUEST_URI} secure
    RewriteRule ^(.*)$ https://www.my_site.com/classes/$1 [R,L]
</Directory>

<Directory "/home/my_site/public_html/secure">
    AllowOverride All
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{REQUEST_URI} secure 
    RewriteRule ^(.*)$ https://www.my_site.com/secure/$1 [R,L]
</Directory>
The problem is that in https://www.my_site.com/secure, I have some paged that include scripts in /home/my_site/public_html/classes with the path $_SERVER['DOCUMENT_ROOT']."/classes/access_user/some_script.php" not a URL, so they are not being served up via HTTPS.

Simply changing the include to "https://my_site.com/classes/access_user/some_script.php"

The problem seems to be the first directive that I'm using to prevent HTTPS access for content that doesn't need it...

What is the solution?

Last edited by Arty Ziff; 12-12-2010 at 12:00 AM.
 
Old 12-18-2010, 01:11 AM   #2
Fullmetal Chocobo
LQ Newbie
 
Registered: Dec 2010
Location: Central Texas
Distribution: Ubuntu (various versions)
Posts: 5

Rep: Reputation: -2
I'm not sure if this will help or not, but my mod_rewrite for sending all traffic to port 443 from 80 is the following:

Code:
RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]
This routes all traffic from the server in that virtual host to https:...
 
Old 12-18-2010, 09:20 AM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
I could be wrong, but I think your problem might be this directive:
Code:
<Directory "/home/my_site/public_html">
    AllowOverride All
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 443 
    RewriteRule ^(.*)$ http://www.my_site.com/$1 [R,L]
</Directory>
I believe that says that if someone visits on port 443 (which is the port used for HTTPS) then you redirect them to the non-HTTPS version of your site. This would effectively prevent anyone from accessing /home/my_site/public_html through anything but regular HTTP.
 
Old 12-18-2010, 06:03 PM   #4
Arty Ziff
Member
 
Registered: May 2008
Location: Tacoma, WA
Distribution: CentOS and RHEL
Posts: 124

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sneakyimp View Post
I could be wrong, but I think your problem might be this directive:
Code:
<Directory "/home/my_site/public_html">
    AllowOverride All
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 443 
    RewriteRule ^(.*)$ http://www.my_site.com/$1 [R,L]
</Directory>
I believe that says that if someone visits on port 443 (which is the port used for HTTPS) then you redirect them to the non-HTTPS version of your site. This would effectively prevent anyone from accessing /home/my_site/public_html through anything but regular HTTP.
Right, but there are two more directives that follow it that address SSL for two specific directories.

My objective is to NOT ALLOW HTTPS on directories that don't need it. Server load and all...
 
Old 12-18-2010, 06:31 PM   #5
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
If you try to access anything in your public_html using HTTPS, that first directive will redirect the request to plain old HTTP and prevent parsing of additional rewrite rules. You would need to alter this rule with some additional RewriteCond directives that exclude your secure subdir and any other dirs where you want to server files HTTPS.

Also, this directive might be useful if your classes directory is full of javascript, but if you are trying this for PHP files it's probably not going to help because included PHP files don't get their own distinct distinct request:
Code:
<Directory "/home/my_site/public_html/classes">
    AllowOverride All
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{REQUEST_URI} secure
    RewriteRule ^(.*)$ https://www.my_site.com/classes/$1 [R,L]
</Directory>
 
  


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
How to import/use CAcert SSL root certificate to use SSL with Xchat IRC client? GrapefruiTgirl Linux - Software 9 04-05-2011 09:54 AM
[SOLVED] ssl.conf and multiple ssl certificastes on Apache kaoticsnow Linux - Server 22 04-08-2010 11:52 PM
vsftpd SSL problem (522 SSL connection failed) stringZ Linux - Server 8 05-05-2009 02:27 PM
creating an SSL page under non SSL site with apache1.33? taiwf Linux - Software 1 06-27-2006 01:06 AM
SSL Connections / second and SSL Accelerator Cards on Linux LinuxGeek Linux - Networking 0 06-10-2006 08:18 AM

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

All times are GMT -5. The time now is 06:48 PM.

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