LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-15-2009, 03:30 PM   #1
patrickg28
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Rep: Reputation: 15
Apache applying SSL settings to all ports..need help plz


I'm using CentOS 5.3 with Apache 2.2.3

I recently obtained a signed SSL certificate from Comodo.

When I turn the SLL engine on, the SSL works on port 443 no problem. - But when I try to go to other virtual addresses from my virtual hosts, they are all SSL and won't allow regular http.

For example, on port 80, I have a non secure site http://myserver.com. On port 443, I have a secure site https://mysecureserver.com

As soon as I turn SSL engine to "on" in the ssl.conf file, I can properly go to https://mysecureserver.com (and everything works...says its secure etc.) but if I try to go to http://myserver.com it says:

"Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please."

I have my servers setup as follows:

default server:
port: any
address: any
server name: myserver.com

virtual server1:
port: 80
address: http://myserver.com
server name: myserver.com

virtual server2:
port: 443
address: http://mysecureserver.com
server name: myserver.com


Here are the pertinent things in my ssl.conf:

Listen: *:443

<VirtualHost mysecureserver.com:443>

# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

SSLEngine on

SSLProtocol all -SSLv2


# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile server.com.crt

# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile server.com.key

# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
#SSLCertificateChainFile server-bundle

# Certificate Authority (CA):
# Set the CA certificate verification path where to find CA
# certificates for client authentication or alternatively one
# huge file containing all of them (file must be PEM encoded)
SSLCACertificateFile server.crt


# Client Authentication (Type):
# Client certificate verification type and depth. Types are
# none, optional, require and optional_no_ca. Depth is a
# number which specifies how deeply to verify the certificate
# issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth 10



</VirtualHost>
 
Old 07-15-2009, 04:23 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You need these
Code:
Listen: 80 
Listen 443
NameVirtualHost *:80
NameVirtualHost *:443
along with the vhosts definitions that should be changed to:
<VirtualHost *:80>
ServerName myserver.com
...
</VirtualHost>

<VirtualHost *:443>
ServerName myserver.com
...
</VirtualHost>

Last edited by bathory; 07-15-2009 at 05:48 PM.
 
Old 07-15-2009, 04:35 PM   #3
patrickg28
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
re:

Quote:
Originally Posted by bathory View Post
You need these
Code:
Listen: 80 443
NameVirtualHost *:80
NameVirtualHost *:443
along with the vhosts definitions that should be changed to:
<VirtualHost *:80>
ServerName myserver.com
...
</VirtualHost>

<VirtualHost *:443>
ServerName myserver.com
...
</VirtualHost>
Now I get this when trying to start apache:

Starting httpd: [error] VirtualHost myserver.com:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

[error] VirtualHost mysecureserver.com:443 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

[error] VirtualHost myserver.com:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

[FAILED]
 
Old 07-15-2009, 04:40 PM   #4
patrickg28
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
here is my server config

here's the config in webmin:
Attached Thumbnails
Click image for larger version

Name:	error.JPG
Views:	20
Size:	128.4 KB
ID:	999  
 
Old 07-15-2009, 05:02 PM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
I cannot say from the webmin screenshot what's wrong.
You have to check httpd.conf and any included vhosts files that all use the same notation (in this case *:80 for non secure and *:443 for secure vhosts) and in the NameVirtualHost directive(s).
 
Old 07-15-2009, 05:19 PM   #6
patrickg28
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
Here are my SSL.CONF and HTTPD.CONF files

Quote:
Originally Posted by bathory View Post
I cannot say from the webmin screenshot what's wrong.
You have to check httpd.conf and any included vhosts files that all use the same notation (in this case *:80 for non secure and *:443 for secure vhosts) and in the NameVirtualHost directive(s).
Okay .. thanks for the help ... attached are my httpd.conf and ssl.conf files (used webmin to configure these...so I wouldn't be surprised if there's lots of wrong stuff in there..but other than my SSL problem, it works).

Last edited by patrickg28; 07-15-2009 at 07:59 PM.
 
Old 07-15-2009, 05:33 PM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
After making a backup of the 2 files change the following:
Code:
ssl.conf
Listen 80
Listen 443
..
<VirtualHost *:443>
Code:
httpd.conf
NameVirtualHost *.80
NameVirtualHost *.443
If you need also the vhost *:4727, then you must add that port in the Listen directive and also add another NameVirtualHost.
Check also the other config files in conf.d/*.conf, there should be the definitions for vhosts listening on port 80.

***EDIT***
Looking at the vhosts examples, it looks like apache wants 2 different Listen directives to specify 2 different ports

Last edited by bathory; 07-15-2009 at 05:49 PM. Reason: config error
 
Old 07-15-2009, 05:50 PM   #8
patrickg28
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
re:

Quote:
Originally Posted by bathory View Post
After making a backup of the 2 files change the following:
Code:
ssl.conf
Listen 80
Listen 443
..
<VirtualHost *:443>
Code:
httpd.conf
NameVirtualHost *.80
NameVirtualHost *.443
If you need also the vhost *:4727, then you must add that port in the Listen directive and also add another NameVirtualHost.
Check also the other config files in conf.d/*.conf, there should be the definitions for vhosts listening on port 80.

***EDIT***
Looking at the vhosts examples, it looks like apache wants 2 different Listen directives to specify 2 different ports

Thanks, can you be a bit more specific with the above ... I'm assuming you are expecting me to plug this into a synthax, but I am a newbie...

if I just copy/paste the exact lines above in the files, I get synthax errors
 
Old 07-15-2009, 06:07 PM   #9
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You don't have to copy/paste, but you must edit the specified directives accordingly and add the ones that don't exist.
So in httpd.conf you replace "NameVirtualHost 64.15.74.92" with the 2 lines:
Code:
NameVirtualHost *:80
NameVirtualHost *:443
Replace "<VirtualHost servername:80>" with:
Code:
<VirtualHost *:80>
Also it's better to add
Code:
Listen 80
in this file and not in ssl.conf.

In ssl.conf remove "Listen *:80", change "Listen *:443", to:
Code:
Listen 443
and <VirtualHost secureservername:443> to
Code:
<VirtualHost *:443>
 
Old 07-15-2009, 06:22 PM   #10
patrickg28
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
Re:

Quote:
Originally Posted by bathory View Post
You don't have to copy/paste, but you must edit the specified directives accordingly and add the ones that don't exist.
So in httpd.conf you replace "NameVirtualHost 64.15.74.92" with the 2 lines:
Code:
NameVirtualHost *:80
NameVirtualHost *:443
Replace "<VirtualHost servername:80>" with:
Code:
<VirtualHost *:80>
Also it's better to add
Code:
Listen 80
in this file and not in ssl.conf.

In ssl.conf remove "Listen *:80", change "Listen *:443", to:
Code:
Listen 443
and <VirtualHost secureservername:443> to
Code:
<VirtualHost *:443>

GREAT .. that worked... now I can get the non ssl site on port 80 and I can get the SSL site on port 443. .. BUT .. now I get an error when loading the SSL site ..it's still secure but I get this in a popup:

"You have requested an encrypted page that contains non encrypted information" Information that you see or enter on this site could be easily seen by a 3rd party"...

Did not get that error before when loading the SSL...

In my ignorant views here, I am thinking maybe it's because somehow now the secure site is being partially loaded on port 80 ?
 
Old 07-15-2009, 06:47 PM   #11
patrickg28
LQ Newbie
 
Registered: Jun 2009
Posts: 25

Original Poster
Rep: Reputation: 15
Nevermind, I figued it out. I had some links in the SSL page that were defined as "http://blahblah.com" and with port 80 closed, they just didn't load up.

Now that it's open, they load up and are not secure.


Thanks again for your help!!
 
  


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
vsFTPd - SSL connection and dynamic SSL ports toxoplasme Linux - Server 11 08-22-2008 10:50 PM
Applying SSL to certain files/page within the website karen.pertierra Linux - General 5 01-22-2007 08:38 AM
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
mixing * ports error in apache + ssl xushi Slackware 1 09-21-2004 10:03 AM
Applying Network Settings dlocalized Linux - Newbie 1 12-12-2003 09:13 AM

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

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