LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 03-26-2007, 05:16 PM   #1
Biggen
Member
 
Registered: Sep 2004
Location: Panama City Beach FL
Distribution: Slackware 12.2
Posts: 199

Rep: Reputation: 31
Apache SSL how-to??


I been scouring over the net trying to find a good tutorial on how to get Apache rolling with SSL. Apache is installed properly WITH mod_SSL but this is about as far as I can go. The whole CA, .CRT, .key, thing is a little overwhelming to someone who has never used this stuff before. All I want to due is secure a particular part of my website (not with passwords but with SSL). For example, I don't want to secure the entire www.website.com. I only want to secure, www.website.com/dir (that particular directory and all its subs).

I would have thought it would be easy to do this but nothing is every easy with Apache. You'd think they would have a tutuorial on their site but dont... Any help or links would be appreciated...
 
Old 03-26-2007, 07:50 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
That's how it works, SSL will be enabled on the domain you specify. It can't just specify a sub-directory. You can use SSL or HTTPS just for the directory after the domain, perhaps setup a mod-rewrite rule if you want to force yourself or users to use HTTPS on it once you setup the SSL certificate for your domain.
 
Old 03-26-2007, 08:03 PM   #3
Alfar
LQ Newbie
 
Registered: Dec 2006
Posts: 15

Rep: Reputation: 0
Smile Here is a configuration file you can follow as an initial setup

I am a bit new to this myself but hope this can help. You need to generate a key in /etc/apache2 on Debian you just run apach2-ssl-certificate.

Then an example is as follows,

Listen 80
Listen 443

NameVirtualHost 192.168.1.1:80


#ensures connections over port 80 are forwarded to the ssl site
<VirtualHost www.site.com:80>
RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L]
DocumentRoot /usr/share/squirrelmail
ServerName www.site.com
ServerAlias alias.com
ErrorLog /var/log/apache2/web_mail80_error.log
TransferLog /var/log/apache2/web_mail80_access.log
ServerAdmin postmaster@site.com
</VirtualHost>

#load the ssl certificate you generated
SSLCertificateFile /etc/apache2/ssl/apache.pem

NameVirtualHost 192.168.1.1:443

#the secure site
<VirtualHost www.site.com:443>
SSLEngine On
DocumentRoot /usr/share/squirrelmail
ServerName www.site.com
ServerAlias alias.com
ErrorLog /var/log/apache2/web_mail_error.log
TransferLog /var/log/apache2/web_mail_access.log
ServerAdmin postmaster@site.com
</VirtualHost>

I will find out about how to secure particular directories because i need to know this myself soon. I will post here what i find.

Most likely you need to put SSLEngine On inside a <Directory> stanza.

Hope this helps
Regards
Alfar
 
Old 03-26-2007, 08:14 PM   #4
Biggen
Member
 
Registered: Sep 2004
Location: Panama City Beach FL
Distribution: Slackware 12.2
Posts: 199

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by trickykid
That's how it works, SSL will be enabled on the domain you specify. It can't just specify a sub-directory. You can use SSL or HTTPS just for the directory after the domain, perhaps setup a mod-rewrite rule if you want to force yourself or users to use HTTPS on it once you setup the SSL certificate for your domain.
Ok, so even though SSL will be setup on www.mysite.com, I can restrict the use of https on that particular directory. I can live with that. :-) I'll check into the mod-rewrite rules.

Alfar:

Looks as if you are doing the EXACT same thing I am. I am wanting to secure the squirrel mail directory too! :-) I have figured out I need keys but then I guess I also need certificates, and then I need a CA (which I can be one) that has to sign the certificate... *sigh* Man, SSL is a pain the rear to setup.

I will give your setup a try and for now, go ahead and secure the entire document root. I'll take a look myself (as well with you) in finding out how to secure one particular directory...
 
Old 03-26-2007, 08:37 PM   #5
Alfar
LQ Newbie
 
Registered: Dec 2006
Posts: 15

Rep: Reputation: 0
Yes i didnt want my squirrelmail users to transmit their passwords in clear text. IF this is what you're trying to do, then i suggest you go ahead and encrypt a whole site. Create a DNS entry for your server, something like mail.site.com instead of www. This would be easy to remmember.

I assume you would not have the key certified by a CA (because at least for UK its around £500 per site with verisign). If that is so, then a problem might arise with viewing the site in IE. Basically an annoying page pops up saying that the key cannot be verified. They have to click on "Continue not recommended" every time, and most people naturally panic when something is red and not recommended. In firefox all you have to do is click on accept certificate permanently. I dont know why Microsoft is soo paranoid about certificates where it is not bothered about so many other problems with security and their products.
 
Old 03-30-2007, 10:47 AM   #6
Biggen
Member
 
Registered: Sep 2004
Location: Panama City Beach FL
Distribution: Slackware 12.2
Posts: 199

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by Alfar
Yes i didnt want my squirrelmail users to transmit their passwords in clear text. IF this is what you're trying to do, then i suggest you go ahead and encrypt a whole site. Create a DNS entry for your server, something like mail.site.com instead of www. This would be easy to remmember.

I assume you would not have the key certified by a CA (because at least for UK its around £500 per site with verisign). If that is so, then a problem might arise with viewing the site in IE. Basically an annoying page pops up saying that the key cannot be verified. They have to click on "Continue not recommended" every time, and most people naturally panic when something is red and not recommended. In firefox all you have to do is click on accept certificate permanently. I dont know why Microsoft is soo paranoid about certificates where it is not bothered about so many other problems with security and their products.
Just an update. Went ahead and bought a Godaddy.com Turbo SSL certificate for $20. It expires in a year, but $20 is pretty damn cheap.

Also, I figured out how to get users to the secured directory when browsing the non-secure site. Whenever a use wants to connect to http://www.example.com/mail, a simple "Redirect" command in the Virtual Host section of my .conf file causes them to go to https://www.example.com/mail which is the SSL encrypted site. Piece of cake!!

Thanks for all the help!
 
Old 04-05-2007, 01:31 PM   #7
Alfar
LQ Newbie
 
Registered: Dec 2006
Posts: 15

Rep: Reputation: 0
Quote:
Originally Posted by Biggen
Just an update. Went ahead and bought a Godaddy.com Turbo SSL certificate for $20. It expires in a year, but $20 is pretty damn cheap.

Also, I figured out how to get users to the secured directory when browsing the non-secure site. Whenever a use wants to connect to http://www.example.com/mail, a simple "Redirect" command in the Virtual Host section of my .conf file causes them to go to https://www.example.com/mail which is the SSL encrypted site. Piece of cake!!

Thanks for all the help!
Thanks for the info. I secured my exim curier and apache for $35 for 2 years.
 
Old 04-18-2007, 10:30 PM   #8
jamesballin
LQ Newbie
 
Registered: Jan 2007
Location: NM
Distribution: Fedora Core 6
Posts: 2

Rep: Reputation: 0
Apache 2.2.3 Redirecting to https from http

Apache 2.2.3 Redirecting to https from http

Hello everyone! This is my first time here, but I am looking for a little advise on VirtualHost and running port 443 the same time that I am listening on port 80. I have "Listen 80" and "Listen 443" defined in my httpd.conf file, and this is what I have defined in the VirtualHost section of httpd.conf:

<VirtualHost *:80>
DocumentRoot /var/www/html/example
ServerName www.example.com
ErrorLog logs/example.error_log
CustomLog logs/example.com_access common
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/html/example
ServerName www.example.com
Redirect https://www.example.com:443 https://www.example.com/register.cgi
ErrorLog logs/example.error_log
CustomLog logs/example.com_access common
SSLEngine On
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/certs/localhost.key
</VirtualHost>


I want to be able to listen on port 80 for the normal traffic of the site, and then when the user decided to register a user=name they can log in securely on port 443. It tells me that if I run "apachectl -t" that the port 80 takes precedence of the ports, and syntax is Ok. Also, if I run from a browser: "http://www.example.com", the server runs just fine; and if I type the URL: "https://www.example.com" it will tell about the untrusted certificate files since I am running a self-signed certificate.

If anybody could help me out it would be wonderful...thanks all
 
  


Reply



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
Apache 1.3.33 (debian built) and Apache SSL does not respond to the proper ports lqorg_user Linux - Networking 0 11-06-2005 04:11 PM
apache and apache-ssl questions merana Debian 4 03-10-2005 10:10 AM
Apache and SSL PcHammer Linux - Software 3 02-18-2005 02:33 PM
apache-ssl opabil Linux - Networking 0 11-03-2004 07:26 AM
Apache with ssl The Insider Linux - Newbie 0 03-03-2004 04:26 AM

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

All times are GMT -5. The time now is 01:30 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