# SSL, ZenCart and Virtual Host. Something is wrong



## Omega_Shadow (Aug 2, 2004)

this &*$% server is fighting me the entire way and I am sick of it  
I just want this software installed and working. For referance, here is the site I am working with:
www.owwpaintball.com

On this server I have around 13 other websites, all working fine. However, this is the ONLY site that needs to be used with SSL. I beleive I screwed up in my httpd.conf file when I made the Virtual Host entry for the site, but I don't know how to change it. I created it just like I did the others.

Any info you need, let me know and you got it. I want this up and running so I dont have to worry about it anymore. It has been a long month of fighting this damn server just for this particular webpage and I am about to "fix" the problem with a large hammer!!


----------



## tomdkat (May 6, 2006)

First, if you're gonna be the system admin doing this kind of work you've got to be ready for problems and learning curves.  So, get a cup of your favorite beverage, take a sip, take a deep breath, and let's get to work.  Nothing will "just work" without some kind of knowledge to get it to work. If this isn't your thing, find or hire another sys admin and save yourself grief and agony. 

With that being stated, please post the *entire* VirtualHost definition for the site in question, along with versions of Apache and ZenCart you are working with. 

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

Ah, an old friend. Things are looking up already 

I will (unfortanatly) be the sys admin. I was hired on to fix simple computer problems and data entry. Now I am building servers and makeing websites. I would not mind the challange if I had been givin a chance to learn or even buy a damn book or something, but insted I am flying by the seat of my pants here and I hate it. Thus, the reason I am so agrivated. I am sure I could figure this out if I just had a little more time and a lot more referance / learning matirials

But hey, thus is life. Back down to a cool level and ready to learn

My Virtual Host Block from httpd.conf. Websites other then the one's I am working on have been ommited because they are customer sites

```
NameVirtualHost 192.168.1.210
<VirtualHost 192.168.1.210>
	ServerName www.outpostpaintball.com
	ServerAlias outpostpaintball.com *.outpostpaintball.com
	DocumentRoot "/www/outpostpaintball"
</VirtualHost>

<VirtualHost 192.168.1.210>
        ServerName www.chaospaintballfields.com
        ServerAlias chaospaintballfields.com *.chaospaintballfields.com
        DocumentRoot "/www/chaos"
</VirtualHost>

<VirtualHost 192.168.1.210>
        ServerName www.owwpaintball.com
        ServerAlias owwpaintball.com *.owwpaintball.com
        DocumentRoot "/www/oww"
</VirtualHost>
```
Now, from looking at the Vitual Host right after reading this (http://glasnost.beeznest.org/articles/347) I _think_ I should add the line "Name VirtualHost *.443" and then make a virtual host just for ssl. Is that correct or am I on the wrong track?

Also, would it be a bad idea to change "Name VirtualHost 192.168.1.210" to "Name VirtualHost *:80" and make the change to all virtual host entries? Or is the way I have it the proper way?

BTW, Apache is 2.2 and Zencart is 1.3.7.1


----------



## tomdkat (May 6, 2006)

Omega_Shadow said:


> Ah, an old friend. Things are looking up already
> 
> I will (unfortanatly) be the sys admin. I was hired on to fix simple computer problems and data entry. Now I am building servers and makeing websites. I would not mind the challange if I had been givin a chance to learn or even buy a damn book or something, but insted I am flying by the seat of my pants here and I hate it. Thus, the reason I am so agrivated. I am sure I could figure this out if I just had a little more time and a lot more referance / learning matirials
> 
> But hey, thus is life. Back down to a cool level and ready to learn


Gotcha. In that case, see if you can get your employer to pay for LARGE quantities of your favorite beverage, on top of your normal wage/salary.  Some of this stuff is a serious pain in the rear to setup but once you're over that hump, you will gain knowledge that can and will help in the future, since you WILL be viewed as "the expert". 

Now, let's get down to business.....



> My Virtual Host Block from httpd.conf. Websites other then the one's I am working on have been ommited because they are customer sites
> 
> (snip)
> 
> Now, from looking at the Vitual Host right after reading this (http://glasnost.beeznest.org/articles/347) I _think_ I should add the line "Name VirtualHost *.443" and then make a virtual host just for ssl. Is that correct or am I on the wrong track?


First, don't be seduced by use of the word "ease" on that page. 

Read these links to make sure this will actually work for you:

http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#vhosts
(This is from the Apache 2.2 docs)

http://www.onlamp.com/pub/a/apache/2005/02/17/apacheckbk.html
http://www.networkworld.com/columnists/2006/011606internet.html



> Also, would it be a bad idea to change "Name VirtualHost 192.168.1.210" to "Name VirtualHost *:80" and make the change to all virtual host entries? Or is the way I have it the proper way?


I suggest you don't follow those instructions "blindly" just to get things working. You should apply the info in those instructions along with the other info that's out there. Based on the Apache 2.2 docs, I'm thinking this might be possible:


```
NameVirtualHost 192.168.1.210[b]:80[/b]
NameVirtualHost 192.168.1.210[b]:443[/b]
<VirtualHost 192.168.1.210[b]:80[/b]>
	ServerName www.outpostpaintball.com
	ServerAlias outpostpaintball.com *.outpostpaintball.com
	DocumentRoot "/www/outpostpaintball"
</VirtualHost>

<VirtualHost 192.168.1.210[b]:80[/b]>
        ServerName www.chaospaintballfields.com
        ServerAlias chaospaintballfields.com *.chaospaintballfields.com
        DocumentRoot "/www/chaos"
</VirtualHost>

<VirtualHost 192.168.1.210[b]:443[/b]>
        ServerName www.owwpaintball.com
        ServerAlias owwpaintball.com *.owwpaintball.com
[b]
        SSLEngine on
        SSLCertificateFile /path/to/www.domain.com.cert
        SSLCertificateKeyFile /path/to/www.domain.com.key
[/b]
        DocumentRoot "/www/oww"
</VirtualHost>
```
 Experiment with that and with replacing 192.168.1.210 with * and see what happens. Apache's error_log will be your friend so monitor it throughout all this to see what Apache complains about. Lastly, be sure to have the Apache Virtual Hosts documentation handy. 

Good luck and let us know how things go. 

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

ok, looks like I got some reading to do.

First I edited the virtual hosts much like that one page had it. That didnt work. Then I made the changes you had posted, which made a whole lot more sense. Still notta

So I decided to make the following changes

```
NameVirtualHost 192.168.1.210:80
NameVirtualHost 192.168.1.210:443
<VirtualHost 192.168.1.210:80>
	ServerName www.outpostpaintball.com
	ServerAlias outpostpaintball.com *.outpostpaintball.com
	DocumentRoot "/www/outpostpaintball"
</VirtualHost>

<VirtualHost 192.168.1.210:80>
        ServerName www.chaospaintballfields.com
        ServerAlias chaospaintballfields.com *.chaospaintballfields.com
        DocumentRoot "/www/chaos"
</VirtualHost>

[B]<VirtualHost 192.168.1.210:[COLOR="Red"]80[/COLOR]>
        ServerName www.owwpaintball.com
        ServerAlias owwpaintball.com *.owwpaintball.com
        DocumentRoot "/www/oww"

</VirtualHost>[/B]

[B]<VirtualHost 192.168.1.210:[COLOR="#ff0000"]443[/COLOR]>
        ServerName www.owwpaintball.com
        ServerAlias owwpaintball.com *.owwpaintball.com
        SSLEngine on
        SSLCertificateFile /usr/local/etc/apache22/server.crt
        SSLCertificateKeyFile /usr/local/etc/apache22/server.key
        DocumentRoot "/www/oww"

</VirtualHost>[/B]
```
AND IT WORKS. So step one is done. But I have found another problem as expected and I think this one will be easy. I need to make another server cert/key. When I made this one I think I made it useing the wrong name as it pulls up my name instead of the server name. Attached is the exact error as seen in the Opera Web Browser.

I am trying to remember how to create a server key and cert but I seem to have misplaced that little documentation. Could you point me toward an howto?

Also, I am getting sick of rebooting the server. I am almost positive you can restart apache without rebooting the server but for the life of me I cant find the command. Would you know what that is?


----------



## tomdkat (May 6, 2006)

Omega_Shadow said:


> AND IT WORKS. So step one is done.


Great! 



> But I have found another problem as expected and I think this one will be easy. I need to make another server cert/key. When I made this one I think I made it useing the wrong name as it pulls up my name instead of the server name. Attached is the exact error as seen in the Opera Web Browser.
> 
> I am trying to remember how to create a server key and cert but I seem to have misplaced that little documentation. Could you point me toward an howto?


Sorry, can't help there.



> Also, I am getting sick of rebooting the server. I am almost positive you can restart apache without rebooting the server but for the life of me I cant find the command. Would you know what that is?


Of course. 

As an aside, you should rarely have to actually reboot a Unix server when configuring the various daemons that run on it. Sending the daemon a SIGHUP or killing it and restarting it are usually all that's needed. I admin a Linux server remotely and I'm upgrading Apache or SpamAssassin or ClamAV without having to reboot the actual server at all. 

Lastly, you should schedule a "graceful" restart of Apache every so often (maybe nightly) to keep its resource usage under control. On the box I admin, I have graceful restarts scheduled nightly and a full restart scheduled monthly.

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

No idea how this happend but now all my sites are down! Apache wont start!


```
[[email protected] ~]# /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
[[email protected] ~]# /usr/local/etc/rc.d/apache22 status
apache22 is not running.
[[email protected] ~]#
```
Last thing I did was attempt a graceful restart after some changes to httpd.conf. It failed as it was typed

```
/usr/local/etc/rc.d/apache22 -k graceful
```
 so I removed the "-k" and it seemed to work. But then I noticed all my sites were not comming up. Tied a reboot but that did not help


----------



## tomdkat (May 6, 2006)

tomdkat said:


> Apache's error_log will be your friend so monitor it throughout all this to see what Apache complains about.


So, what's in the error log?

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

good question. I have been looking for said error log for a while now.


----------



## tomdkat (May 6, 2006)

Ok, try this command:

# find /usr/local -name "error*"

See what hits you get.

EDIT: Or you can look in httpd.conf to see where errors will be logged.

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

that is a nifty command. I am going to have to remember that. Is there a switch to that command to exclude directories from the output?

Ok, I think I know what happend but not sure how to change it. Here is the error output:
[Thu Nov 29 00:17:50 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Thu Nov 29 00:17:50 2007] [error] Unable to configure RSA server private key
[Thu Nov 29 00:17:50 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch


----------



## tomdkat (May 6, 2006)

Ok, cool. For now, disable the SSL site and get your server back up. Then, you can play with the SSL stuff using a different instance of Apache.

Make a copy of httpd.conf called "httpd-ssl-test.conf" or something like that. In that, configure the server to listen on some other port, like port 4242 or 8069, anything other than port 80. Change the name of the PID file for this test server to some test name (you'll see it in httpd.conf) so it won't conflict with the production Apache server. Change the name of the error file to something different too.

Then, fire up the test Apache server like this:

# /usr/local/apache/bin/apachectl -f /usr/local/apache/conf/httpd-ssl-test.conf &

Then, you can get the SSL stuff worked out without keeping your production server offline.

Make sense?

With regard to the SSL stuff, that RSA server certificate warning is something that should be addressed along with the errors.

Good luck!

Peace...


----------



## tomdkat (May 6, 2006)

Omega_Shadow said:


> that is a nifty command. I am going to have to remember that. Is there a switch to that command to exclude directories from the output?


See what man find tells you. 

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

ok, here is the problem. I removed SSL instances completely in the vertual host block and my websites are still not up. I dont know what to do!


----------



## tomdkat (May 6, 2006)

Again, what does the Apache error log have in it after you restart the server after removing the SSL stuff?

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

same thing as above, different time stamp


----------



## tomdkat (May 6, 2006)

```
NameVirtualHost 192.168.1.210:80
[b][color="red"]NameVirtualHost 192.168.1.210:443[/color][/b]
<VirtualHost 192.168.1.210:80>
	ServerName www.outpostpaintball.com
	ServerAlias outpostpaintball.com *.outpostpaintball.com
	DocumentRoot "/www/outpostpaintball"
</VirtualHost>

<VirtualHost 192.168.1.210:80>
        ServerName www.chaospaintballfields.com
        ServerAlias chaospaintballfields.com *.chaospaintballfields.com
        DocumentRoot "/www/chaos"
</VirtualHost>

<VirtualHost 192.168.1.210:80>
        ServerName www.owwpaintball.com
        ServerAlias owwpaintball.com *.owwpaintball.com
        DocumentRoot "/www/oww"

</VirtualHost>

[B][color="red"]<VirtualHost 192.168.1.210:443>
        ServerName www.owwpaintball.com
        ServerAlias owwpaintball.com *.owwpaintball.com
        SSLEngine on
        SSLCertificateFile /usr/local/etc/apache22/server.crt
        SSLCertificateKeyFile /usr/local/etc/apache22/server.key
        DocumentRoot "/www/oww"

</VirtualHost>[/color][/B]
```
Did you remove the stuff in red above or did you simply remove the SSL directives? Remove the stuff in red and see if your server starts.

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

Yes, that is exactly what I removed. Server does not start


----------



## tomdkat (May 6, 2006)

If the error log STILL mentions SSL certificates, you've missed something. So, please post the latest error log so I can see what errors are being reported.

Thanks!

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

I can varify that if I missed something, it aint in the httpd.conf file. Is there any other file that I might have to edit? I have only edited the httpd.conf file in the last three weeks so I am very confused right now.

Here is the last part of the error log:

```
[Wed Nov 28 22:26:23 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Wed Nov 28 22:26:23 2007] [error] Unable to configure RSA server private key
[Wed Nov 28 22:26:23 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Wed Nov 28 22:33:19 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Wed Nov 28 22:33:19 2007] [error] Unable to configure RSA server private key
[Wed Nov 28 22:33:19 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Wed Nov 28 23:31:39 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Wed Nov 28 23:31:39 2007] [error] Unable to configure RSA server private key
[Wed Nov 28 23:31:39 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Wed Nov 28 23:41:26 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Wed Nov 28 23:41:26 2007] [error] Unable to configure RSA server private key
[Wed Nov 28 23:41:26 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Thu Nov 29 00:17:50 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Thu Nov 29 00:17:50 2007] [error] Unable to configure RSA server private key
[Thu Nov 29 00:17:50 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Thu Nov 29 15:57:45 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Thu Nov 29 15:57:45 2007] [error] Unable to configure RSA server private key
[Thu Nov 29 15:57:45 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[Thu Nov 29 18:21:00 2007] [warn] RSA server certificate CommonName (CN) `www.owwpaintball.com' does NOT match server name!?
[Thu Nov 29 18:21:00 2007] [error] Unable to configure RSA server private key
[Thu Nov 29 18:21:00 2007] [error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
```


----------



## tomdkat (May 6, 2006)

How are you trying to start the server? What command are you issuing?

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

```
[[email protected] ~]# /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
[[email protected] ~]# /usr/local/etc/rc.d/apache22 status
apache22 is not running.
[[email protected] ~]#WTF!?
-bash: !?: event not found
```


----------



## tomdkat (May 6, 2006)

Ok, please check your inbox.

Peace...


----------



## tomdkat (May 6, 2006)

Ok, can you take a peek at /usr/local/etc/rc.d/apache22 and see if there are any explicit references to httpd.conf in it? 

Peace...


----------



## tomdkat (May 6, 2006)

Ok, please disregard my last PM. I didn't scroll down. 

I see this in your httpd.conf file:

# Secure (SSL/TLS) connections
Include etc/apache22/extra/httpd-ssl.conf

Comment OUT this line then see if you can bring your server up:

# Secure (SSL/TLS) connections
#Include etc/apache22/extra/httpd-ssl.conf

Also, please look inside that httpd-ssl.conf file to see what's in it that might be interfering.

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

server is now running. That did it. Thanx. I would have reported this earlyer but I had to have a meeting with my boss about the server downtime. You can guess how that went


----------



## tomdkat (May 6, 2006)

Yep, I can imagine.  Take a peek in httpd-ssl.conf to see what it had in it and see if you can determine WHY you had SSL configuration settings in two different config files.

I strongly suggest you setup a second set of config files, as described above, so you can do your SSL work without impacting the production server.

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

I never made a httpd-sll.conf file, or edited it for that matter. This is the first time I have heard of it. Posting now....


```
#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailing information about these 
# directives see <URL:http://httpd.apache.org/docs/2.2/mod/mod_ssl.html>
# 
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#

#
# Pseudo Random Number Generator (PRNG):
# Configure one or more sources to seed the PRNG of the SSL library.
# The seed data should be of good random quality.
# WARNING! On some platforms /dev/random blocks if not enough entropy
# is available. This means you then cannot use the /dev/random device
# because it would lead to very long connection times (as long as
# it requires to make more entropy available). But usually those
# platforms additionally provide a /dev/urandom device which doesn't
# block. So, if available, use this one instead. Read the mod_ssl User
# Manual for more details.
#
#SSLRandomSeed startup file:/dev/random  512
#SSLRandomSeed startup file:/dev/urandom 512
#SSLRandomSeed connect file:/dev/random  512
#SSLRandomSeed connect file:/dev/urandom 512


#
# When we also provide SSL we have to listen to the 
# standard HTTP port (see above) and to the HTTPS port
#
# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two
#       Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"
#
Listen 443

##
##  SSL Global Context
##
##  All SSL configuration in this context applies both to
##  the main server and all SSL-enabled virtual hosts.
##

#
#   Some MIME-types for downloading Certificates and CRLs
#
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl

#   Pass Phrase Dialog:
#   Configure the pass phrase gathering process.
#   The filtering dialog program (`builtin' is a internal
#   terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog  builtin

#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism 
#   to use and second the expiring timeout (in seconds).
#SSLSessionCache         "dbm:/var/run/ssl_scache"
SSLSessionCache        "shmcb:/var/run/ssl_scache(512000)"
SSLSessionCacheTimeout  300

#   Semaphore:
#   Configure the path to the mutual exclusion semaphore the
#   SSL engine uses internally for inter-process synchronization. 
SSLMutex  "file:/var/run/ssl_mutex"

##
## SSL Virtual Host Context
##

<VirtualHost _default_:443>

#   General setup for the virtual host
DocumentRoot "/usr/local/www/apache22/data"
ServerName www.example.com:443
ServerAdmin [email protected]
ErrorLog "/var/log/httpd-error.log"
TransferLog "/var/log/httpd-access.log"

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on

#   SSL Cipher Suite:
#   List the ciphers that the client is permitted to negotiate.
#   See the mod_ssl documentation for a complete list.
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

#   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.  Keep
#   in mind that if you have both an RSA and a DSA certificate you
#   can configure both in parallel (to also allow the use of DSA
#   ciphers, etc.)
SSLCertificateFile "/usr/local/etc/apache22/server.crt"
#SSLCertificateFile "/usr/local/etc/apache22/server-dsa.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 "/usr/local/etc/apache22/server.key"
#SSLCertificateKeyFile "/usr/local/etc/apache22/server-dsa.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 "/usr/local/etc/apache22/server-ca.crt"

#   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)
#   Note: Inside SSLCACertificatePath you need hash symlinks
#         to point to the certificate files. Use the provided
#         Makefile to update the hash symlinks after changes.
#SSLCACertificatePath "/usr/local/etc/apache22/ssl.crt"
#SSLCACertificateFile "/usr/local/etc/apache22/ssl.crt/ca-bundle.crt"

#   Certificate Revocation Lists (CRL):
#   Set the CA revocation path where to find CA CRLs for client
#   authentication or alternatively one huge file containing all
#   of them (file must be PEM encoded)
#   Note: Inside SSLCARevocationPath you need hash symlinks
#         to point to the certificate files. Use the provided
#         Makefile to update the hash symlinks after changes.
#SSLCARevocationPath "/usr/local/etc/apache22/ssl.crl"
#SSLCARevocationFile "/usr/local/etc/apache22/ssl.crl/ca-bundle.crl"

#   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

#   Access Control:
#   With SSLRequire you can do per-directory access control based
#   on arbitrary complex boolean expressions containing server
#   variable checks and other lookup directives.  The syntax is a
#   mixture between C and Perl.  See the mod_ssl documentation
#   for more details.
#<Location />
#SSLRequire (    %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
#            and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
#            and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
#            and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \
#            and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20       ) \
#           or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
#</Location>

#   SSL Engine Options:
#   Set various options for the SSL engine.
#   o FakeBasicAuth:
#     Translate the client X.509 into a Basic Authorisation.  This means that
#     the standard Auth/DBMAuth methods can be used for access control.  The
#     user name is the `one line' version of the client's X.509 certificate.
#     Note that no password is obtained from the user. Every entry in the user
#     file needs this password: `xxj31ZMTZzkVA'.
#   o ExportCertData:
#     This exports two additional environment variables: SSL_CLIENT_CERT and
#     SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
#     server (always existing) and the client (only existing when client
#     authentication is used). This can be used to import the certificates
#     into CGI scripts.
#   o StdEnvVars:
#     This exports the standard SSL/TLS related `SSL_*' environment variables.
#     Per default this exportation is switched off for performance reasons,
#     because the extraction step is an expensive operation and is usually
#     useless for serving static content. So one usually enables the
#     exportation for CGI and SSI requests only.
#   o StrictRequire:
#     This denies access when "SSLRequireSSL" or "SSLRequire" applied even
#     under a "Satisfy any" situation, i.e. when it applies access is denied
#     and no other module can change it.
#   o OptRenegotiate:
#     This enables optimized SSL connection renegotiation handling when SSL
#     directives are used in per-directory context. 
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/usr/local/www/apache22/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

#   SSL Protocol Adjustments:
#   The safe and default but still SSL/TLS standard compliant shutdown
#   approach is that mod_ssl sends the close notify alert but doesn't wait for
#   the close notify alert from client. When you need a different shutdown
#   approach you can use one of the following variables:
#   o ssl-unclean-shutdown:
#     This forces an unclean shutdown when the connection is closed, i.e. no
#     SSL close notify alert is send or allowed to received.  This violates
#     the SSL/TLS standard but is needed for some brain-dead browsers. Use
#     this when you receive I/O errors because of the standard approach where
#     mod_ssl sends the close notify alert.
#   o ssl-accurate-shutdown:
#     This forces an accurate shutdown when the connection is closed, i.e. a
#     SSL close notify alert is send and mod_ssl waits for the close notify
#     alert of the client. This is 100% SSL/TLS standard compliant, but in
#     practice often causes hanging connections with brain-dead browsers. Use
#     this only for browsers where you know that their SSL implementation
#     works correctly. 
#   Notice: Most problems of broken clients are also related to the HTTP
#   keep-alive facility, so you usually additionally want to disable
#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
#   "force-response-1.0" for this.
BrowserMatch ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

#   Per-Server Logging:
#   The home of a custom SSL log file. Use this when you want a
#   compact non-error SSL logfile on a virtual host basis.
CustomLog "/var/log/httpd-ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>
```
I still think I got a pretty non-standard configuration from all the copy-poste I did from various readme's and howto's. Do you know of a good guide for makeing a server from the ground up on FreeBSD while actualy explaining whats going on? Eventaly I want to rebuild this server


----------



## tomdkat (May 6, 2006)

Omega_Shadow said:


> I never made a httpd-sll.conf file, or edited it for that matter. This is the first time I have heard of it. Posting now....


Well, that file was configuring Apache to listen on port 443 as well as turning on the SSL engine and setting up a default virtual host for SSL requests. Since you attempted to create a certificate previously, the directives in httpd-ssl.conf that setup the SSL support "tripped" over your certificate and that prevented the server from starting.

You should check the dates on the certificate and key files:

SSLCertificateFile "/usr/local/etc/apache22/server.crt"
SSLCertificateKeyFile "/usr/local/etc/apache22/server.key"

and delete (or rename) the ones with datestamps around the day you created your certificate, just as a safety precaution.



> I still think I got a pretty non-standard configuration from all the copy-poste I did from various readme's and howto's.


Not really. The only thing that jumps out at me is you having your virtual hosts defined at the top of httpd.conf instead of them being defined in httpd-vhosts.conf (or whatever the name of the included file is). Back in the Apache 1.3.x days, virtual hosts were usually defined at or near the end of httpd.conf. Then, in either Apache 2.0 or 2.2, the default location became the httpd-vhosts.conf file that's included in httpd.conf. On the Apache 2.0 server I admin, I have about 20-30 virtual hosts defined at the end of my httpd.conf file. I really need to delete the obsolete site definitions to make the file smaller. 



> Do you know of a good guide for makeing a server from the ground up on FreeBSD while actualy explaining whats going on? Eventaly I want to rebuild this server


Nope, I'm not a FreeBSD guy. I would imagine it wouldn't be much different from other Unix systems other than how you get things installed (building from source or using some pre-packaged bundle of some kind).

It's not magic or anything, you just have to learn a bunch a stuff.  I suggest printing out your httpd.conf file and reading it while you're in the bathroom or something. You won't need to memorize all the directives but you really should be familiar with a number of them. I would also pour over the docs at the Apache website (which is why I keep posting links to them ) since they contain a ton of valuable information as well.

Another suggestion: get familiar with how each component works and fits into the puzzle, then you will have an easier time isolating problems when a piece of the puzzle breaks. You've got a web server, PHP scripting environment, RDBMS, SSL and possibly other components you should have some kind of working knowledge of to effectively administer the server. This is partly why sys admins can make good money. 

Good luck!

Peace...


----------



## Omega_Shadow (Aug 2, 2004)

I am looking foreword to understanding COMPLETELY how webservers work. I am pooring over all the docs in the ../../apache22/extras folder and checking out the appache site, but I would like to know more. Like how PHP works and how it is connected to appache, how everything interacts with eachother, why MySQL is such a ***** p) among other things. I am looking into a book(s) that might help me get started like when I got started with linux. Are there any suggestions you have in this realm?


----------



## tomdkat (May 6, 2006)

Omega_Shadow said:


> I am looking foreword to understanding COMPLETELY how webservers work. I am pooring over all the docs in the ../../apache22/extras folder and checking out the appache site, but I would like to know more.


Sounds good.



> Like how PHP works and how it is connected to appache,


You can start here. Focus on PHP being related to a CGI solution and I think your understanding will be far more useful. PHP can be integrated with several web servers but if you understand CGI and what purpose it serves, you'll be able to see how PHP fits in to the picture more easily. 



> why MySQL is such a *****


Now THIS is a question I have as well.  :up:



> Are there any suggestions you have in this realm?


I would start with online tutorials and O'Reilly books.

Peace...


----------

