Chapter 14. Web Servers
- Apache HTTP Server
- nginx
Important
14.1. The Apache HTTP Server
httpd, an open source web server developed by the Apache Software Foundation.
httpd service configuration accordingly. This section reviews some of the newly added features, outlines important changes between Apache HTTP Server 2.4 and version 2.2, and guides you through the update of older configuration files.
14.1.1. Notable Changes
- httpd Service Control
- With the migration away from SysV init scripts, server administrators should switch to using the
apachectlandsystemctlcommands to control the service, in place of theservicecommand. The following examples are specific to thehttpdservice.The command:service httpd graceful
is replaced byapachectl graceful
Thesystemdunit file forhttpdhas different behavior from the init script as follows:The command:- A graceful restart is used by default when the service is reloaded.
- A graceful stop is used by default when the service is stopped.
service httpd configtest
is replaced byapachectl configtest
- Private /tmp
- To enhance system security, the
systemdunit file runs thehttpddaemon using a private/tmpdirectory, separate to the system/tmpdirectory. - Configuration Layout
- Configuration files which load modules are now placed in the
/etc/httpd/conf.modules.d/directory. Packages that provide additional loadable modules forhttpd, such as php, will place a file in this directory. AnIncludedirective before the main section of the/etc/httpd/conf/httpd.conffile is used to include files within the/etc/httpd/conf.modules.d/directory. This means any configuration files withinconf.modules.d/are processed before the main body ofhttpd.conf. AnIncludeOptionaldirective for files within the/etc/httpd/conf.d/directory is placed at the end of thehttpd.conffile. This means the files within/etc/httpd/conf.d/are now processed after the main body ofhttpd.conf.Some additional configuration files are provided by the httpd package itself:/etc/httpd/conf.d/autoindex.conf— This configures mod_autoindex directory indexing./etc/httpd/conf.d/userdir.conf— This configures access to user directories, for example,http://example.com/~username/; such access is disabled by default for security reasons./etc/httpd/conf.d/welcome.conf— As in previous releases, this configures the welcome page displayed forhttp://localhost/when no content is present.
- Default Configuration
- A minimal
httpd.conffile is now provided by default. Many common configuration settings, such asTimeoutorKeepAliveare no longer explicitly configured in the default configuration; hard-coded settings will be used instead, by default. The hard-coded default settings for all configuration directives are specified in the manual. See the section called “Installable Documentation” for more information. - Incompatible Syntax Changes
- If migrating an existing configuration from httpd 2.2 to httpd 2.4, a number of backwards-incompatible changes to the
httpdconfiguration syntax were made which will require changes. See the following Apache document for more information on upgrading http://httpd.apache.org/docs/2.4/upgrading.html - Processing Model
- In previous releases of Red Hat Enterprise Linux, different multi-processing models (MPM) were made available as different
httpdbinaries: the forked model, “prefork”, as/usr/sbin/httpd, and the thread-based model “worker” as/usr/sbin/httpd.worker.In Red Hat Enterprise Linux 7, only a singlehttpdbinary is used, and three MPMs are available as loadable modules: worker, prefork (default), and event. Edit the configuration file/etc/httpd/conf.modules.d/00-mpm.confas required, by adding and removing the comment character#so that only one of the three MPM modules is loaded. - Packaging Changes
- The LDAP authentication and authorization modules are now provided in a separate sub-package, mod_ldap. The new module mod_session and associated helper modules are provided in a new sub-package, mod_session. The new modules mod_proxy_html and mod_xml2enc are provided in a new sub-package, mod_proxy_html. These packages are all in the Optional channel.
Note
Before subscribing to the Optional and Supplementary channels see the Scope of Coverage Details. If you decide to install packages from these channels, follow the steps documented in the article called How to access Optional and Supplementary channels, and -devel packages using Red Hat Subscription Manager (RHSM)? on the Red Hat Customer Portal. - Packaging Filesystem Layout
- The
/var/cache/mod_proxy/directory is no longer provided; instead, the/var/cache/httpd/directory is packaged with aproxyandsslsubdirectory.Packaged content provided withhttpdhas been moved from/var/www/to/usr/share/httpd/:/usr/share/httpd/icons/— The directory containing a set of icons used with directory indices, previously contained in/var/www/icons/, has moved to/usr/share/httpd/icons/. Available athttp://localhost/icons/in the default configuration; the location and the availability of the icons is configurable in the/etc/httpd/conf.d/autoindex.conffile./usr/share/httpd/manual/— The/var/www/manual/has moved to/usr/share/httpd/manual/. This directory, contained in the httpd-manual package, contains the HTML version of the manual forhttpd. Available athttp://localhost/manual/if the package is installed, the location and the availability of the manual is configurable in the/etc/httpd/conf.d/manual.conffile./usr/share/httpd/error/— The/var/www/error/has moved to/usr/share/httpd/error/. Custom multi-language HTTP error pages. Not configured by default, the example configuration file is provided at/usr/share/doc/httpd-VERSION/httpd-multilang-errordoc.conf.
- Authentication, Authorization and Access Control
- The configuration directives used to control authentication, authorization and access control have changed significantly. Existing configuration files using the
Order,DenyandAllowdirectives should be adapted to use the newRequiresyntax. See the following Apache document for more information http://httpd.apache.org/docs/2.4/howto/auth.html - suexec
- To improve system security, the suexec binary is no longer installed as if by the
rootuser; instead, it has file system capability bits set which allow a more restrictive set of permissions. In conjunction with this change, the suexec binary no longer uses the/var/log/httpd/suexec.loglogfile. Instead, log messages are sent to syslog; by default these will appear in the/var/log/securelog file. - Module Interface
- Third-party binary modules built against httpd 2.2 are not compatible with httpd 2.4 due to changes to the
httpdmodule interface. Such modules will need to be adjusted as necessary for the httpd 2.4 module interface, and then rebuilt. A detailed list of the API changes in version2.4is available here: http://httpd.apache.org/docs/2.4/developer/new_api_2_4.html.The apxs binary used to build modules from source has moved from/usr/sbin/apxsto/usr/bin/apxs. - Removed modules
- List of
httpdmodules removed in Red Hat Enterprise Linux 7:- mod_auth_mysql, mod_auth_pgsql
- httpd 2.4 provides SQL database authentication support internally in the mod_authn_dbd module.
- mod_perl
- mod_perl is not officially supported with httpd 2.4 by upstream.
- mod_authz_ldap
- httpd 2.4 provides LDAP support in sub-package mod_ldap using mod_authnz_ldap.
14.1.2. Updating the Configuration
- Make sure all module names are correct, since they may have changed. Adjust the
LoadModuledirective for each module that has been renamed. - Recompile all third party modules before attempting to load them. This typically means authentication and authorization modules.
- If you use the Apache HTTP Secure Server, see Section 14.1.8, “Enabling the mod_ssl Module” for important information on enabling the Secure Sockets Layer (SSL) protocol.
~]# apachectl configtest
Syntax OK14.1.3. Running the httpd Service
httpd service, make sure you have the httpd installed. You can do so by using the following command:
~]# yum install httpd14.1.3.1. Starting the Service
httpd service, type the following at a shell prompt as root:
~]# systemctl start httpd.service~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.Note
14.1.3.2. Stopping the Service
httpd service, type the following at a shell prompt as root:
~]# systemctl stop httpd.service~]# systemctl disable httpd.service
Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service.14.1.3.3. Restarting the Service
httpd service:
- To restart the service completely, enter the following command as
root:~]#
systemctl restart httpd.serviceThis stops the runninghttpdservice and immediately starts it again. Use this command after installing or removing a dynamically loaded module such as PHP. - To only reload the configuration, as
root, type:~]#
systemctl reload httpd.serviceThis causes the runninghttpdservice to reload its configuration file. Any requests currently being processed will be interrupted, which may cause a client browser to display an error message or render a partial page. - To reload the configuration without affecting active requests, enter the following command as
root:~]#
apachectl gracefulThis causes the runninghttpdservice to reload its configuration file. Any requests currently being processed will continue to use the old configuration.
14.1.4. Editing the Configuration Files
httpd service is started, by default, it reads the configuration from locations that are listed in Table 14.1, “The httpd service configuration files”.
Table 14.1. The httpd service configuration files
httpd service.
~]# apachectl configtest
Syntax OK14.1.5. Working with Modules
httpd service is distributed along with a number of Dynamic Shared Objects (DSOs), which can be dynamically loaded or unloaded at runtime as necessary. On Red Hat Enterprise Linux 7, these modules are located in /usr/lib64/httpd/modules/.
14.1.5.1. Loading a Module
LoadModule directive. Note that modules provided by a separate package often have their own configuration file in the /etc/httpd/conf.d/ directory.
Example 14.1. Loading the mod_ssl DSO
LoadModule ssl_module modules/mod_ssl.so
httpd service.
14.1.5.2. Writing a Module
root:
~]# yum install httpd-develapxs) utility required to compile a module.
~]# apxs -i -a -c module_name.c14.1.6. Setting Up Virtual Hosts
/usr/share/doc/httpd-VERSION/httpd-vhosts.conf into the /etc/httpd/conf.d/ directory, and replace the @@Port@@ and @@ServerRoot@@ placeholder values. Customize the options according to your requirements as shown in Example 14.2, “Example virtual host configuration”.
Example 14.2. Example virtual host configuration
<VirtualHost *:80>
ServerAdmin webmaster@penguin.example.com
DocumentRoot "/www/docs/penguin.example.com"
ServerName penguin.example.com
ServerAlias www.penguin.example.com
ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
</VirtualHost>ServerName must be a valid DNS name assigned to the machine. The <VirtualHost> container is highly customizable, and accepts most of the directives available within the main server configuration. Directives that are not supported within this container include User and Group, which were replaced by SuexecUserGroup.
Note
Listen directive in the global settings section of the /etc/httpd/conf/httpd.conf file accordingly.
httpd service.
14.1.7. Setting Up an SSL Server
mod_ssl, a module that uses the OpenSSL toolkit to provide the SSL/TLS support, is commonly referred to as the SSL server. Red Hat Enterprise Linux also supports the use of Mozilla NSS as the TLS implementation. Support for Mozilla NSS is provided by the mod_nss module.
14.1.7.1. An Overview of Certificates and Security
Table 14.2. Information about CA lists used by common web browsers
| Web Browser | Link |
|---|---|
| Mozilla Firefox | Mozilla root CA list. |
| Opera | Information on root certificates used by Opera. |
| Internet Explorer | Information on root certificates used by Microsoft Windows. |
| Chromium | Information on root certificates used by the Chromium project. |
14.1.8. Enabling the mod_ssl Module
mod_ssl, you cannot have the another application or module, such as mod_nss configured to use the same port. Port 443 is the default port for HTTPS.
mod_ssl module and the OpenSSL toolkit, install the mod_ssl and openssl packages. Enter the following command as root:
~]# yum install mod_ssl opensslmod_ssl configuration file at /etc/httpd/conf.d/ssl.conf, which is included in the main Apache HTTP Server configuration file by default. For the module to be loaded, restart the httpd service as described in Section 14.1.3.3, “Restarting the Service”.
Important
SSL and using only TLSv1.1 or TLSv1.2. Backwards compatibility can be achieved using TLSv1.0. Many products Red Hat supports have the ability to use SSLv2 or SSLv3 protocols, or enable them by default. However, the use of SSLv2 or SSLv3 is now strongly recommended against.
14.1.8.1. Enabling and Disabling SSL and TLS in mod_ssl
SSLProtocol directive in the “## SSL Global Context” section of the configuration file and removing it everywhere else, or edit the default entry under “# SSL Protocol support” in all “VirtualHost” sections. If you do not specify it in the per-domain VirtualHost section then it will inherit the settings from the global section. To make sure that a protocol version is being disabled the administrator should either only specify SSLProtocol in the “SSL Global Context” section, or specify it in all per-domain VirtualHost sections.
Procedure 14.1. Disable SSLv2 and SSLv3
- As
root, open the/etc/httpd/conf.d/ssl.conffile and search for all instances of theSSLProtocoldirective. By default, the configuration file contains one section that looks as follows:~]#
This section is within the VirtualHost section.vi /etc/httpd/conf.d/ssl.conf# SSL Protocol support: # List the enable protocol levels with which clients will be able to # connect. Disable SSLv2 access by default: SSLProtocol all -SSLv2 - Edit the
SSLProtocolline as follows:# SSL Protocol support: # List the enable protocol levels with which clients will be able to # connect. Disable SSLv2 access by default: SSLProtocol all -SSLv2 -SSLv3
Repeat this action for all VirtualHost sections. Save and close the file. - Verify that all occurrences of the
SSLProtocoldirective have been changed as follows:~]#
This step is particularly important if you have more than the one default VirtualHost section.grep SSLProtocol /etc/httpd/conf.d/ssl.confSSLProtocol all -SSLv2 -SSLv3 - Restart the Apache daemon as follows:
~]#
Note that any sessions will be interrupted.systemctl restart httpd
Procedure 14.2. Disable All SSL and TLS Protocols Except TLS 1 and Up
- As
root, open the/etc/httpd/conf.d/ssl.conffile and search for all instances ofSSLProtocoldirective. By default the file contains one section that looks as follows:~]#
vi /etc/httpd/conf.d/ssl.conf# SSL Protocol support: # List the enable protocol levels with which clients will be able to # connect. Disable SSLv2 access by default: SSLProtocol all -SSLv2 - Edit the
SSLProtocolline as follows:# SSL Protocol support: # List the enable protocol levels with which clients will be able to # connect. Disable SSLv2 access by default: SSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2
Save and close the file. - Verify the change as follows:
~]#
grep SSLProtocol /etc/httpd/conf.d/ssl.confSSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2 - Restart the Apache daemon as follows:
~]#
Note that any sessions will be interrupted.systemctl restart httpd
Procedure 14.3. Testing the Status of SSL and TLS Protocols
openssl s_client -connect command. The command has the following form: openssl s_client -connect hostname:port -protocolWhere port is the port to test and protocol is the protocol version to test for. To test the SSL server running locally, use
localhost as the host name. For example, to test the default port for secure HTTPS connections, port 443 to see if SSLv3 is enabled, issue a command as follows:
~]#
The above output indicates that the handshake failed and therefore no cipher was negotiated.openssl s_client -connect localhost:443 -ssl3CONNECTED(00000003) 139809943877536:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1257:SSL alert number 40 139809943877536:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:596: output omitted New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE SSL-Session: Protocol : SSLv3 output truncated~]$
The above output indicates that no failure of the handshake occurred and a set of ciphers was negotiated.openssl s_client -connect localhost:443 -tls1_2CONNECTED(00000003) depth=0 C = --, ST = SomeState, L = SomeCity, O = SomeOrganization, OU = SomeOrganizationalUnit, CN = localhost.localdomain, emailAddress = root@localhost.localdomain output omitted New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384 Server public key is 2048 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE SSL-Session: Protocol : TLSv1.2 output truncated
openssl s_client command options are documented in the s_client(1) manual page.
14.1.9. Enabling the mod_nss Module
mod_nss, you cannot have the mod_ssl package installed with its default settings as mod_ssl will use port 443 by default, however this is the default HTTPS port. If at all possible, remove the package.
root:
~]# yum remove mod_sslNote
mod_ssl is required for other purposes, modify the /etc/httpd/conf.d/ssl.conf file to use a port other than 443 to prevent mod_ssl conflicting with mod_nss when its port to listen on is changed to 443.
mod_nss and mod_ssl can only co-exist at the same time if they use unique ports. For this reason mod_nss by default uses 8443, but the default port for HTTPS is port 443. The port is specified by the Listen directive as well as in the VirtualHost name or address.
Procedure 14.4. Configuring mod_nss
- Install mod_nss as
root:~]#
yum install mod_nssThis will create themod_nssconfiguration file at/etc/httpd/conf.d/nss.conf. The/etc/httpd/conf.d/directory is included in the main Apache HTTP Server configuration file by default. For the module to be loaded, restart thehttpdservice as described in Section 14.1.3.3, “Restarting the Service”. - As
root, open the/etc/httpd/conf.d/nss.conffile and search for all instances of theListendirective.Edit theListen 8443line as follows:Listen 443
Port443is the default port forHTTPS. - Edit the default
VirtualHost _default_:8443line as follows:VirtualHost _default_:443
Edit any other non-default virtual host sections if they exist. Save and close the file. - Mozilla NSS stores certificates in a server certificate database indicated by the
NSSCertificateDatabasedirective in the/etc/httpd/conf.d/nss.conffile. By default the path is set to/etc/httpd/alias, the NSS database created during installation.To view the default NSS database, issue a command as follows:~]#
In the above command output,certutil -L -d /etc/httpd/aliasCertificate Nickname Trust Attributes SSL,S/MIME,JAR/XPI cacert CTu,Cu,Cu Server-Cert u,u,u alpha u,pu,uServer-Certis the defaultNSSNickname. The-Loption lists all the certificates, or displays information about a named certificate, in a certificate database. The-doption specifies the database directory containing the certificate and key database files. See thecertutil(1)man page for more command line options. - To configure mod_nss to use another database, edit the
NSSCertificateDatabaseline in the/etc/httpd/conf.d/nss.conffile. The default file has the following lines within the VirtualHost section.# Server Certificate Database: # The NSS security database directory that holds the certificates and # keys. The database consists of 3 files: cert8.db, key3.db and secmod.db. # Provide the directory that these files exist. NSSCertificateDatabase /etc/httpd/alias
In the above command output,aliasis the default NSS database directory,/etc/httpd/alias/. - To apply a password to the default NSS certificate database, use the following command as
root:~]#
certutil -W -d /etc/httpd/aliasEnter Password or Pin for "NSS Certificate DB": Enter a password which will be used to encrypt your keys. The password should be at least 8 characters long, and should contain at least one non-alphabetic character. Enter new password: Re-enter password: Password changed successfully. - Before deploying the HTTPS server, create a new certificate database using a certificate signed by a certificate authority (CA).
Example 14.3. Adding a Certificate to the Mozilla NSS database
Thecertutilcommand is used to add a CA certificate to the NSS database files:certutil-d/etc/httpd/nss-db-directory/-A-n"CA_certificate"-tCT,,-a-icertificate.pemThe above command adds a CA certificate stored in a PEM-formatted file named certificate.pem. The-doption specifies the NSS database directory containing the certificate and key database files, the-noption sets a name for the certificate,-tCT,,means that the certificate is trusted to be used in TLS clients and servers. The-Aoption adds an existing certificate to a certificate database. If the database does not exist it will be created. The-aoption allows the use of ASCII format for input or output, and the-ioption passes thecertificate.peminput file to the command.See thecertutil(1)man page for more command line options. - The NSS database should be password protected to safeguard the private key.
Example 14.4. Setting a Password for a Mozilla NSS database
Thecertutiltool can be used set a password for an NSS database as follows:certutil -W -d /etc/httpd/nss-db-directory/
For example, for the default database, issue a command asrootas follows:~]#
certutil -W -d /etc/httpd/aliasEnter Password or Pin for "NSS Certificate DB": Enter a password which will be used to encrypt your keys. The password should be at least 8 characters long, and should contain at least one non-alphabetic character. Enter new password: Re-enter password: Password changed successfully. - Configure
mod_nssto use the NSS internal software token by changing the line with theNSSPassPhraseDialogdirective as follows:~]#
This is to avoid manual password entry on system start. The software token exists in the NSS database but you can also have a physical token containing your certificates.vi /etc/httpd/conf.d/nss.confNSSPassPhraseDialog file:/etc/httpd/password.conf - If the SSL Server Certificate contained in the NSS database is an RSA certificate, make certain that the
NSSNicknameparameter is uncommented and matches the nickname displayed in step 4 above:~]#
vi /etc/httpd/conf.d/nss.confNSSNickname Server-CertIf the SSL Server Certificate contained in the NSS database is an ECC certificate, make certain that theNSSECCNicknameparameter is uncommented and matches the nickname displayed in step 4 above:~]#
vi /etc/httpd/conf.d/nss.confNSSECCNickname Server-CertMake certain that theNSSCertificateDatabaseparameter is uncommented and points to the NSS database directory displayed in step 4 or configured in step 5 above:~]#
Replacevi /etc/httpd/conf.d/nss.confNSSCertificateDatabase /etc/httpd/alias/etc/httpd/aliaswith the path to the certificate database to be used. - Create the
/etc/httpd/password.conffile asroot:~]#
Add a line with the following form:vi /etc/httpd/password.confinternal:password
Replacing password with the password that was applied to the NSS security databases in step 6 above. - Apply the appropriate ownership and permissions to the
/etc/httpd/password.conffile:~]#
chgrp apache /etc/httpd/password.conf~]#chmod 640 /etc/httpd/password.conf~]#ls -l /etc/httpd/password.conf-rw-r-----. 1 root apache 10 Dec 4 17:13 /etc/httpd/password.conf - To configure
mod_nssto use the NSS the software token in/etc/httpd/password.conf, edit/etc/httpd/conf.d/nss.confas follows:~]#
vi /etc/httpd/conf.d/nss.conf - Restart the Apache server for the changes to take effect as described in Section 14.1.3.3, “Restarting the Service”
Important
SSL and using only TLSv1.1 or TLSv1.2. Backwards compatibility can be achieved using TLSv1.0. Many products Red Hat supports have the ability to use SSLv2 or SSLv3 protocols, or enable them by default. However, the use of SSLv2 or SSLv3 is now strongly recommended against.
14.1.9.1. Enabling and Disabling SSL and TLS in mod_nss
NSSProtocol directive in the “## SSL Global Context” section of the configuration file and removing it everywhere else, or edit the default entry under “# SSL Protocol” in all “VirtualHost” sections. If you do not specify it in the per-domain VirtualHost section then it will inherit the settings from the global section. To make sure that a protocol version is being disabled the administrator should either only specify NSSProtocol in the “SSL Global Context” section, or specify it in all per-domain VirtualHost sections.
Procedure 14.5. Disable All SSL and TLS Protocols Except TLS 1 and Up in mod_nss
- As
root, open the/etc/httpd/conf.d/nss.conffile and search for all instances of theNSSProtocoldirective. By default, the configuration file contains one section that looks as follows:~]#
This section is within the VirtualHost section.vi /etc/httpd/conf.d/nss.conf# SSL Protocol: output omitted # Since all protocol ranges are completely inclusive, and no protocol in the # middle of a range may be excluded, the entry "NSSProtocol SSLv3,TLSv1.1" # is identical to the entry "NSSProtocol SSLv3,TLSv1.0,TLSv1.1". NSSProtocol SSLv3,TLSv1.0,TLSv1.1 - Edit the
NSSProtocolline as follows:# SSL Protocol: NSSProtocol TLSv1.0,TLSv1.1
Repeat this action for all VirtualHost sections. - Edit the
Listen 8443line as follows:Listen 443
- Edit the default
VirtualHost _default_:8443line as follows:VirtualHost _default_:443
Edit any other non-default virtual host sections if they exist. Save and close the file. - Verify that all occurrences of the
NSSProtocoldirective have been changed as follows:~]#
This step is particularly important if you have more than one VirtualHost section.grep NSSProtocol /etc/httpd/conf.d/nss.conf# middle of a range may be excluded, the entry "NSSProtocol SSLv3,TLSv1.1" # is identical to the entry "NSSProtocol SSLv3,TLSv1.0,TLSv1.1". NSSProtocol TLSv1.0,TLSv1.1 - Restart the Apache daemon as follows:
~]#
Note that any sessions will be interrupted.service httpd restart
Procedure 14.6. Testing the Status of SSL and TLS Protocols in mod_nss
openssl s_client -connect command. Install the openssl package as root:
~]# yum install openssl
openssl s_client -connect command has the following form: openssl s_client -connect hostname:port -protocolWhere port is the port to test and protocol is the protocol version to test for. To test the SSL server running locally, use
localhost as the host name. For example, to test the default port for secure HTTPS connections, port 443 to see if SSLv3 is enabled, issue a command as follows:
~]#
The above output indicates that the handshake failed and therefore no cipher was negotiated.openssl s_client -connect localhost:443 -ssl3CONNECTED(00000003) 3077773036:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:s3_pkt.c:337: output omitted New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE SSL-Session: Protocol : SSLv3 output truncated~]$
The above output indicates that no failure of the handshake occurred and a set of ciphers was negotiated.openssl s_client -connect localhost:443 -tls1CONNECTED(00000003) depth=1 C = US, O = example.com, CN = Certificate Shack output omitted New, TLSv1/SSLv3, Cipher is AES128-SHA Server public key is 1024 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE SSL-Session: Protocol : TLSv1 output truncated
openssl s_client command options are documented in the s_client(1) manual page.
14.1.10. Using an Existing Key and Certificate
- You are changing the IP address or domain name.Certificates are issued for a particular IP address and domain name pair. If one of these values changes, the certificate becomes invalid.
- You have a certificate from VeriSign, and you are changing the server software.VeriSign, a widely used certificate authority, issues certificates for a particular software product, IP address, and domain name. Changing the software product renders the certificate invalid.
/etc/pki/tls/private/ and /etc/pki/tls/certs/ directories respectively. You can do so by issuing the following commands as root:
~]#mvkey_file.key/etc/pki/tls/private/hostname.key~]#mvcertificate.crt/etc/pki/tls/certs/hostname.crt
/etc/httpd/conf.d/ssl.conf configuration file:
SSLCertificateFile /etc/pki/tls/certs/hostname.crt SSLCertificateKeyFile /etc/pki/tls/private/hostname.key
httpd service as described in Section 14.1.3.3, “Restarting the Service”.
Example 14.5. Using a key and certificate from the Red Hat Secure Web Server
~]#mv /etc/httpd/conf/httpsd.key /etc/pki/tls/private/penguin.example.com.key~]#mv /etc/httpd/conf/httpsd.crt /etc/pki/tls/certs/penguin.example.com.crt
14.1.11. Generating a New Key and Certificate
root:
~]# yum install crypto-utilsImportant
root, use the following command instead of genkey:
~]# openssl req -x509 -new -set_serial number -key hostname.key -out hostname.crtNote
root:
~]# rm /etc/pki/tls/private/hostname.keygenkey command as root, followed by the appropriate host name (for example, penguin.example.com):
~]# genkey hostname- Review the target locations in which the key and certificate will be stored.

Figure 14.1. Running the genkey utility
Use the Tab key to select the button, and press Enter to proceed to the next screen. - Using the up and down arrow keys, select a suitable key size. Note that while a larger key increases the security, it also increases the response time of your server. The NIST recommends using
2048 bits. See NIST Special Publication 800-131A.
Figure 14.2. Selecting the key size
Once finished, use the Tab key to select the button, and press Enter to initiate the random bits generation process. Depending on the selected key size, this may take some time. - Decide whether you want to send a certificate request to a certificate authority.

Figure 14.3. Generating a certificate request
Use the Tab key to select to compose a certificate request, or to generate a self-signed certificate. Then press Enter to confirm your choice. - Using the Spacebar key, enable (
[*]) or disable ([ ]) the encryption of the private key.
Figure 14.4. Encrypting the private key
Use the Tab key to select the button, and press Enter to proceed to the next screen. - If you have enabled the private key encryption, enter an adequate passphrase. Note that for security reasons, it is not displayed as you type, and it must be at least five characters long.

Figure 14.5. Entering a passphrase
Use the Tab key to select the button, and press Enter to proceed to the next screen.Important
Entering the correct passphrase is required in order for the server to start. If you lose it, you will need to generate a new key and certificate. - Customize the certificate details.

Figure 14.6. Specifying certificate information
Use the Tab key to select the button, and press Enter to finish the key generation. - If you have previously enabled the certificate request generation, you will be prompted to send it to a certificate authority.

Figure 14.7. Instructions on how to send a certificate request
Press Enter to return to a shell prompt.
/etc/httpd/conf.d/ssl.conf configuration file:
SSLCertificateFile /etc/pki/tls/certs/hostname.crt SSLCertificateKeyFile /etc/pki/tls/private/hostname.key
httpd service as described in Section 14.1.3.3, “Restarting the Service”, so that the updated configuration is loaded.
14.1.12. Configure the Firewall for HTTP and HTTPS Using the Command Line
HTTP and HTTPS traffic by default. To enable the system to act as a web server, make use of firewalld's supported services to enable HTTP and HTTPS traffic to pass through the firewall as required.
HTTP using the command line, issue the following command as root:
~]# firewall-cmd --add-service http
success
HTTPS using the command line, issue the following command as root:
~]# firewall-cmd --add-service https
success
--permanent option.
14.1.12.1. Checking Network Access for Incoming HTTPS and HTTPS Using the Command Line
root:
~]# firewall-cmd --list-all
public (default, active)
interfaces: em1
sources:
services: dhcpv6-client ssh
output truncated
In this example taken from a default installation, the firewall is enabled but HTTP and HTTPS have not been allowed to pass through.
HTTP and HTTP firewall services are enabled, the services line will appear similar to the following:
services: dhcpv6-client http https ssh
firewalld, see the Red Hat Enterprise Linux 7 Security Guide.
14.1.13. Additional Resources
Installed Documentation
httpd(8)— The manual page for thehttpdservice containing the complete list of its command-line options.genkey(1)— The manual page forgenkeyutility, provided by the crypto-utils package.apachectl(8)— The manual page for the Apache HTTP Server Control Interface.
Installable Documentation
- http://localhost/manual/ — The official documentation for the Apache HTTP Server with the full description of its directives and available modules. Note that in order to access this documentation, you must have the httpd-manual package installed, and the web server must be running.Before accessing the documentation, issue the following commands as
root:~]#
yum install httpd-manual~]#apachectl graceful
Online Documentation
- http://httpd.apache.org/ — The official website for the Apache HTTP Server with documentation on all the directives and default modules.
- http://www.openssl.org/ — The OpenSSL home page containing further documentation, frequently asked questions, links to the mailing lists, and other useful resources.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.