13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 7 ■ WORKING WITH APACHEAlso check that the permissions on your key and certificate files are set correctly (discussed earlier),as well as the permissions on your test HTML file and its parent directory.Next, check both the main server logs (at /var/log/apache2/error_log) and the SSL logs that you setup in your config file. If you don’t get anything useful, try changing the LogLevel value in the Apache2config file to debug, restart Apache2, and test again to get more log data.If your certificate is in .crt format and you’re having trouble, you could try converting it to .pemformat:openssl x509 -inform der -in MYCERT.cer -out MYCERT.pemThen edit this line in your config file:SSLCertificateFile /etc/apache2/ssl/server.pemIf you’re also running a regular web server on port 80, try fetching a test page via http:// rather thanhttps:// to help identify whether the problem is with the web server or with the SSL connection. Notethat in the previous setup, the web server’s root directory is different for http:// and https://, so youwon’t (or shouldn’t!) be able to access the same content. If your test page in the http:// root directoryworks fine, though, and your test page in the https:// root directory doesn’t, then that can help youpinpoint the problem.If the problem is the SSL connection, a useful tool is s_client, which is a diagnostic tool fortroubleshooting TLS/SSL connections. The basic usage is as follows:/usr/bin/openssl s_client -connect hostname:443There are numerous other options to this command as well, for which you can check thedocumentation. If you get error messages, this should help you in locating the problem.7-5. Securing Your Web Site with htaccessIt’s quite common to have a situation whereby you want to restrict part of your web site to a particularset of users. The next recipe shows a way of doing this via Kerberos if you want users to log in asthemselves, but if you just want to restrict access to people on the local network, htaccess is a quick andstraightforward way to go about this.Let’s say that you want to allow machines only on the local subnet (192.168.*.*) to access the$APACHEROOT/local subdirectory. The first file to set up is $APACHEROOT/local/.htaccess (note the dot); itshould look a bit like this:01 AuthName Local Pages02 AuthType Basic03 04 order deny,allow05 deny from all06 allow from 192.168.07 This will set things up so that the GET and POST methods require an IP from within this range. Denydirectives are read before allow ones (line 04), everything is denied (line 05), and then a specific set of IP167Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!