{"id":50437,"date":"2026-11-23T22:06:18","date_gmt":"2026-11-23T22:06:18","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=50437"},"modified":"2026-11-23T22:06:18","modified_gmt":"2026-11-23T22:06:18","slug":"apache-comprehensive-list-of-apache-http-server-configuration-directives","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/apache-comprehensive-list-of-apache-http-server-configuration-directives\/","title":{"rendered":"Apache: Comprehensive list of Apache HTTP Server configuration directives"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This page lists the Apache HTTP Server 2.4 configuration directives you will see most often in httpd.conf, virtual host files and SSL configs, grouped by function. Below the list you will find which module provides each directive, where it is allowed, a working virtual host and MPM example, a migration table for legacy directives, and the commands to test a configuration before reloading.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a <strong>comprehensive list of Apache HTTP Server configuration directives<\/strong> you might encounter in <code>httpd.conf<\/code> and included config files (like <code>extra\/httpd-vhosts.conf<\/code>, <code>extra\/httpd-ssl.conf<\/code>, etc). Apache has hundreds of directives\u2014here are the most common and important ones, grouped by function. (For a <strong>complete official list<\/strong>, see: <a href=\"https:\/\/httpd.apache.org\/docs\/current\/mod\/directives.html\" rel=\"noopener\">Apache Directives Index<\/a>)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Core Server Directives<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ServerName<\/strong><\/li>\n\n\n\n<li><strong>ServerAlias<\/strong><\/li>\n\n\n\n<li><strong>ServerAdmin<\/strong><\/li>\n\n\n\n<li><strong>DocumentRoot<\/strong><\/li>\n\n\n\n<li><strong>Listen<\/strong><\/li>\n\n\n\n<li><strong>User<\/strong><\/li>\n\n\n\n<li><strong>Group<\/strong><\/li>\n\n\n\n<li><strong>PidFile<\/strong><\/li>\n\n\n\n<li><strong>Timeout<\/strong><\/li>\n\n\n\n<li><strong>KeepAlive<\/strong><\/li>\n\n\n\n<li><strong>KeepAliveTimeout<\/strong><\/li>\n\n\n\n<li><strong>MaxKeepAliveRequests<\/strong><\/li>\n\n\n\n<li><strong>ServerTokens<\/strong><\/li>\n\n\n\n<li><strong>ServerSignature<\/strong><\/li>\n\n\n\n<li><strong>ServerRoot<\/strong><\/li>\n\n\n\n<li><strong>HostnameLookups<\/strong><\/li>\n\n\n\n<li><strong>LimitRequestBody<\/strong><\/li>\n\n\n\n<li><strong>LimitRequestFields<\/strong><\/li>\n\n\n\n<li><strong>LimitRequestFieldSize<\/strong><\/li>\n\n\n\n<li><strong>LimitRequestLine<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Directory and File Handling<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>DirectoryIndex<\/strong><\/li>\n\n\n\n<li><strong>Options<\/strong><\/li>\n\n\n\n<li><strong>AllowOverride<\/strong><\/li>\n\n\n\n<li><strong>Require<\/strong><\/li>\n\n\n\n<li><strong>Order<\/strong> (legacy)<\/li>\n\n\n\n<li><strong>Allow<\/strong> (legacy)<\/li>\n\n\n\n<li><strong>Deny<\/strong> (legacy)<\/li>\n\n\n\n<li><strong>AccessFileName<\/strong><\/li>\n\n\n\n<li><strong>Files<\/strong><\/li>\n\n\n\n<li><strong>Directory<\/strong><\/li>\n\n\n\n<li><strong>Location<\/strong><\/li>\n\n\n\n<li><strong>Alias<\/strong><\/li>\n\n\n\n<li><strong>ScriptAlias<\/strong><\/li>\n\n\n\n<li><strong>IndexOptions<\/strong><\/li>\n\n\n\n<li><strong>IndexIgnore<\/strong><\/li>\n\n\n\n<li><strong>Redirect<\/strong><\/li>\n\n\n\n<li><strong>RedirectMatch<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Logging<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ErrorLog<\/strong><\/li>\n\n\n\n<li><strong>CustomLog<\/strong><\/li>\n\n\n\n<li><strong>LogLevel<\/strong><\/li>\n\n\n\n<li><strong>LogFormat<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Modules and Extensions<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>LoadModule<\/strong><\/li>\n\n\n\n<li><strong>AddModule<\/strong> (legacy)<\/li>\n\n\n\n<li><strong>Include<\/strong><\/li>\n\n\n\n<li><strong>TypesConfig<\/strong><\/li>\n\n\n\n<li><strong>AddType<\/strong><\/li>\n\n\n\n<li><strong>AddHandler<\/strong><\/li>\n\n\n\n<li><strong>AddOutputFilter<\/strong><\/li>\n\n\n\n<li><strong>AddInputFilter<\/strong><\/li>\n\n\n\n<li><strong>AddLanguage<\/strong><\/li>\n\n\n\n<li><strong>AddCharset<\/strong><\/li>\n\n\n\n<li><strong>AddEncoding<\/strong><\/li>\n\n\n\n<li><strong>AddIcon<\/strong><\/li>\n\n\n\n<li><strong>AddDescription<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Performance and Connection Handling<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>StartServers<\/strong><\/li>\n\n\n\n<li><strong>MinSpareServers<\/strong><\/li>\n\n\n\n<li><strong>MaxSpareServers<\/strong><\/li>\n\n\n\n<li><strong>MaxClients<\/strong> (legacy; use MaxRequestWorkers)<\/li>\n\n\n\n<li><strong>MaxRequestWorkers<\/strong><\/li>\n\n\n\n<li><strong>MaxConnectionsPerChild<\/strong><\/li>\n\n\n\n<li><strong>ThreadsPerChild<\/strong><\/li>\n\n\n\n<li><strong>ThreadLimit<\/strong><\/li>\n\n\n\n<li><strong>ServerLimit<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Security and Access Control<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Require<\/strong><\/li>\n\n\n\n<li><strong>AuthType<\/strong><\/li>\n\n\n\n<li><strong>AuthName<\/strong><\/li>\n\n\n\n<li><strong>AuthUserFile<\/strong><\/li>\n\n\n\n<li><strong>AuthGroupFile<\/strong><\/li>\n\n\n\n<li><strong>AuthBasicProvider<\/strong><\/li>\n\n\n\n<li><strong>AllowOverride<\/strong><\/li>\n\n\n\n<li><strong>SSLProtocol<\/strong><\/li>\n\n\n\n<li><strong>SSLCipherSuite<\/strong><\/li>\n\n\n\n<li><strong>SSLCertificateFile<\/strong><\/li>\n\n\n\n<li><strong>SSLCertificateKeyFile<\/strong><\/li>\n\n\n\n<li><strong>SSLCertificateChainFile<\/strong><\/li>\n\n\n\n<li><strong>SSLEngine<\/strong><\/li>\n\n\n\n<li><strong>SSLVerifyClient<\/strong><\/li>\n\n\n\n<li><strong>SSLVerifyDepth<\/strong><\/li>\n\n\n\n<li><strong>SSLProxyEngine<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Virtual Hosting<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>VirtualHost<\/strong><\/li>\n\n\n\n<li><strong>NameVirtualHost<\/strong><\/li>\n\n\n\n<li><strong>UseCanonicalName<\/strong><\/li>\n\n\n\n<li><strong>ServerAlias<\/strong><\/li>\n\n\n\n<li><strong>ServerAdmin<\/strong><\/li>\n\n\n\n<li><strong>DocumentRoot<\/strong><\/li>\n\n\n\n<li><strong>ErrorLog<\/strong><\/li>\n\n\n\n<li><strong>CustomLog<\/strong><\/li>\n\n\n\n<li><strong>SSLEngine<\/strong> (for SSL vhosts)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Proxy and Reverse Proxy<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ProxyRequests<\/strong><\/li>\n\n\n\n<li><strong>ProxyPass<\/strong><\/li>\n\n\n\n<li><strong>ProxyPassReverse<\/strong><\/li>\n\n\n\n<li><strong>ProxyPreserveHost<\/strong><\/li>\n\n\n\n<li><strong>ProxyTimeout<\/strong><\/li>\n\n\n\n<li><strong>ProxyAddHeaders<\/strong><\/li>\n\n\n\n<li><strong>ProxyVia<\/strong><\/li>\n\n\n\n<li><strong>ProxyPassMatch<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>URL Rewriting<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>RewriteEngine<\/strong><\/li>\n\n\n\n<li><strong>RewriteCond<\/strong><\/li>\n\n\n\n<li><strong>RewriteRule<\/strong><\/li>\n\n\n\n<li><strong>RewriteBase<\/strong><\/li>\n\n\n\n<li><strong>RewriteMap<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>MIME Types and Content Handling<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>TypesConfig<\/strong><\/li>\n\n\n\n<li><strong>DefaultType<\/strong><\/li>\n\n\n\n<li><strong>AddType<\/strong><\/li>\n\n\n\n<li><strong>AddEncoding<\/strong><\/li>\n\n\n\n<li><strong>AddLanguage<\/strong><\/li>\n\n\n\n<li><strong>AddCharset<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Other Useful Directives<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SetEnv<\/strong><\/li>\n\n\n\n<li><strong>PassEnv<\/strong><\/li>\n\n\n\n<li><strong>UnsetEnv<\/strong><\/li>\n\n\n\n<li><strong>Header<\/strong><\/li>\n\n\n\n<li><strong>RequestHeader<\/strong><\/li>\n\n\n\n<li><strong>SetHandler<\/strong><\/li>\n\n\n\n<li><strong>ScriptAlias<\/strong><\/li>\n\n\n\n<li><strong>ScriptAliasMatch<\/strong><\/li>\n\n\n\n<li><strong>ScriptInterpreterSource<\/strong><\/li>\n\n\n\n<li><strong>SuexecUserGroup<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Legacy and Deprecated Directives<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">(Some older directives are still seen in configs, though they&#8217;re deprecated)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Order<\/strong><\/li>\n\n\n\n<li><strong>Allow<\/strong><\/li>\n\n\n\n<li><strong>Deny<\/strong><\/li>\n\n\n\n<li><strong>NameVirtualHost<\/strong><\/li>\n\n\n\n<li><strong>MaxClients<\/strong><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Get the Full List on Your Server<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can get a list of all directives supported by your current Apache install with:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">apachectl -L\n<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">or<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">httpd -L\n<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This prints all recognized directives with a brief description.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Official Full List (by Module)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For the <strong>complete and always up-to-date list<\/strong>, see:<br>\ud83d\udc49 <a href=\"https:\/\/httpd.apache.org\/docs\/current\/mod\/directives.html\" rel=\"noopener\">https:\/\/httpd.apache.org\/docs\/current\/mod\/directives.html<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How Apache applies a directive: contexts and merge order<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A directive name on its own is not enough. Every directive is valid only in certain <strong>contexts<\/strong>, and Apache refuses to start if you put one in the wrong place. The official documentation shows the allowed contexts for each directive, and <code>httpd -L<\/code> prints them for compiled-in modules.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Context<\/th><th>Where it lives<\/th><th>Typical directives<\/th><\/tr><\/thead><tbody><tr><td>server config<\/td><td>Top level of <code>httpd.conf<\/code> or an included file<\/td><td><code>Listen<\/code>, <code>ServerRoot<\/code>, <code>LoadModule<\/code>, <code>User<\/code>, MPM settings<\/td><\/tr><tr><td>virtual host<\/td><td>Inside <code>&lt;VirtualHost&gt;<\/code><\/td><td><code>ServerName<\/code>, <code>DocumentRoot<\/code>, <code>SSLEngine<\/code>, <code>ProxyPass<\/code><\/td><\/tr><tr><td>directory<\/td><td>Inside <code>&lt;Directory&gt;<\/code>, <code>&lt;Location&gt;<\/code>, <code>&lt;Files&gt;<\/code><\/td><td><code>Options<\/code>, <code>Require<\/code>, <code>AllowOverride<\/code> (only in <code>&lt;Directory&gt;<\/code>)<\/td><\/tr><tr><td>.htaccess<\/td><td>Per-directory files, only if <code>AllowOverride<\/code> permits it<\/td><td><code>RewriteRule<\/code>, <code>Require<\/code>, <code>AddType<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When several sections match a request, Apache merges them in this order, and later sections override earlier ones: <code>&lt;Directory&gt;<\/code> (non-regex) together with <code>.htaccess<\/code>, then <code>&lt;DirectoryMatch&gt;<\/code>, then <code>&lt;Files&gt;<\/code> and <code>&lt;FilesMatch&gt;<\/code>, then <code>&lt;Location&gt;<\/code> and <code>&lt;LocationMatch&gt;<\/code>, then <code>&lt;If&gt;<\/code>. So a <code>&lt;Location&gt;<\/code> block can override something set in a <code>&lt;Directory&gt;<\/code> block, but the reverse does not happen. Note that <code>Directory<\/code>, <code>Location<\/code>, <code>Files<\/code> and <code>VirtualHost<\/code> in the list above are container sections written with angle brackets, not ordinary directives.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Which module provides each directive<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most directives come from a module. If that module is not loaded, Apache stops with <code>Invalid command &#039;...&#039;, perhaps misspelled or defined by a module not included in the server configuration<\/code>. This table maps the directives listed above to their modules.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Module<\/th><th>Directives from the list above<\/th><\/tr><\/thead><tbody><tr><td>core<\/td><td><code>ServerName<\/code>, <code>ServerAlias<\/code>, <code>ServerAdmin<\/code>, <code>ServerRoot<\/code>, <code>DocumentRoot<\/code>, <code>Timeout<\/code>, <code>KeepAlive*<\/code>, <code>ServerTokens<\/code>, <code>ServerSignature<\/code>, <code>HostnameLookups<\/code>, <code>LimitRequest*<\/code>, <code>Options<\/code>, <code>AllowOverride<\/code>, <code>AccessFileName<\/code>, <code>Include<\/code>, <code>ErrorLog<\/code>, <code>LogLevel<\/code>, <code>SetHandler<\/code>, <code>UseCanonicalName<\/code>, <code>ScriptInterpreterSource<\/code> (Windows only)<\/td><\/tr><tr><td>MPM (prefork, worker, event)<\/td><td><code>Listen<\/code>, <code>PidFile<\/code>, <code>StartServers<\/code>, <code>MaxRequestWorkers<\/code>, <code>MaxConnectionsPerChild<\/code>, <code>ServerLimit<\/code>, <code>ThreadsPerChild<\/code>, <code>ThreadLimit<\/code>; <code>MinSpareServers<\/code> and <code>MaxSpareServers<\/code> are prefork only<\/td><\/tr><tr><td>mod_unixd<\/td><td><code>User<\/code>, <code>Group<\/code><\/td><\/tr><tr><td>mod_so<\/td><td><code>LoadModule<\/code><\/td><\/tr><tr><td>mod_authz_core \/ mod_authz_host<\/td><td><code>Require<\/code><\/td><\/tr><tr><td>mod_authn_core, mod_auth_basic, mod_authn_file, mod_authz_groupfile<\/td><td><code>AuthType<\/code>, <code>AuthName<\/code>, <code>AuthBasicProvider<\/code>, <code>AuthUserFile<\/code>, <code>AuthGroupFile<\/code><\/td><\/tr><tr><td>mod_log_config<\/td><td><code>CustomLog<\/code>, <code>LogFormat<\/code><\/td><\/tr><tr><td>mod_alias<\/td><td><code>Alias<\/code>, <code>ScriptAlias<\/code>, <code>ScriptAliasMatch<\/code>, <code>Redirect<\/code>, <code>RedirectMatch<\/code><\/td><\/tr><tr><td>mod_dir \/ mod_autoindex<\/td><td><code>DirectoryIndex<\/code> \/ <code>IndexOptions<\/code>, <code>IndexIgnore<\/code>, <code>AddIcon<\/code>, <code>AddDescription<\/code><\/td><\/tr><tr><td>mod_mime<\/td><td><code>TypesConfig<\/code>, <code>AddType<\/code>, <code>AddHandler<\/code>, <code>AddOutputFilter<\/code>, <code>AddInputFilter<\/code>, <code>AddLanguage<\/code>, <code>AddCharset<\/code>, <code>AddEncoding<\/code><\/td><\/tr><tr><td>mod_env \/ mod_headers<\/td><td><code>SetEnv<\/code>, <code>PassEnv<\/code>, <code>UnsetEnv<\/code> \/ <code>Header<\/code>, <code>RequestHeader<\/code><\/td><\/tr><tr><td>mod_rewrite, mod_proxy, mod_ssl, mod_suexec<\/td><td><code>Rewrite*<\/code>, <code>Proxy*<\/code>, <code>SSL*<\/code>, <code>SuexecUserGroup<\/code><\/td><\/tr><tr><td>mod_access_compat<\/td><td><code>Order<\/code>, <code>Allow<\/code>, <code>Deny<\/code> (legacy)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On Debian and Ubuntu, enable modules with <code>a2enmod<\/code> (for example <code>sudo a2enmod ssl proxy proxy_http headers rewrite<\/code>). On RHEL, Rocky and Fedora, modules are loaded from <code>\/etc\/httpd\/conf.modules.d\/<\/code>. For optional settings in shared configs, you can wrap them in <code>&lt;IfModule mod_name.c&gt;<\/code> so they apply only when the module is loaded. Avoid this for directives your site depends on, because it hides a missing module instead of failing loudly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A working virtual host that combines the common directives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration below uses most of the core, SSL, proxy, header and logging directives from the list above. It redirects HTTP to HTTPS, serves static files and reverse-proxies <code>\/api\/<\/code> to a local application. It requires mod_ssl, mod_proxy, mod_proxy_http and mod_headers, and a <code>Listen 443<\/code> line, which the default SSL configuration usually provides.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">&lt;VirtualHost *:<span class=\"hljs-number\">80<\/span>&gt;\n    ServerName example.com\n    ServerAlias www.example.com\n    Redirect permanent \/ https:<span class=\"hljs-comment\">\/\/example.com\/<\/span>\n&lt;\/VirtualHost&gt;\n\n&lt;VirtualHost *:<span class=\"hljs-number\">443<\/span>&gt;\n    ServerName example.com\n    ServerAlias www.example.com\n    ServerAdmin webmaster@example.com\n    DocumentRoot \/<span class=\"hljs-keyword\">var<\/span>\/www\/example\n\n    SSLEngine on\n    <span class=\"hljs-comment\"># Certificate plus intermediate chain in one file<\/span>\n    SSLCertificateFile    \/etc\/ssl\/example\/fullchain.pem\n    SSLCertificateKeyFile \/etc\/ssl\/example\/privkey.pem\n\n    &lt;Directory \/<span class=\"hljs-keyword\">var<\/span>\/www\/example&gt;\n        Options -Indexes +FollowSymLinks\n        AllowOverride None\n        <span class=\"hljs-keyword\">Require<\/span> all granted\n    &lt;\/Directory&gt;\n\n    <span class=\"hljs-comment\"># Reverse proxy; ProxyRequests stays Off (the default)<\/span>\n    ProxyPreserveHost On\n    ProxyPass        \/api\/ http:<span class=\"hljs-comment\">\/\/127.0.0.1:8080\/<\/span>\n    ProxyPassReverse \/api\/ http:<span class=\"hljs-comment\">\/\/127.0.0.1:8080\/<\/span>\n\n    Header always set Strict-Transport-Security <span class=\"hljs-string\">\"max-age=31536000\"<\/span>\n    Header always set X-Content-Type-Options <span class=\"hljs-string\">\"nosniff\"<\/span>\n\n    <span class=\"hljs-comment\"># Adjust log paths for your distribution (\/var\/log\/apache2 on Debian)<\/span>\n    ErrorLog  \/<span class=\"hljs-keyword\">var<\/span>\/log\/httpd\/example_error.log\n    CustomLog \/<span class=\"hljs-keyword\">var<\/span>\/log\/httpd\/example_access.log combined\n&lt;\/VirtualHost&gt;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>ServerName<\/code> and <code>ServerAlias<\/code> decide which name-based virtual host answers a request. If no name matches, the <strong>first<\/strong> vhost defined for that IP and port answers.<\/li>\n\n\n<li><code>Options -Indexes<\/code> turns off directory listings. <code>AllowOverride None<\/code> stops Apache from looking for <code>.htaccess<\/code> files, which is safer and faster.<\/li>\n\n\n<li><code>ProxyPreserveHost On<\/code> forwards the original <code>Host<\/code> header to the backend. <code>ProxyPassReverse<\/code> rewrites <code>Location<\/code> headers in backend redirects so clients are not sent to <code>127.0.0.1<\/code>.<\/li>\n\n\n<li><code>Header always set<\/code> adds the header to error responses as well, not only to 2xx responses.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Never set <code>ProxyRequests On<\/code> on a reverse proxy. It turns the server into a forward proxy, and if access is not restricted, anyone can use it as an open proxy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tuning the MPM directives together<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The performance directives depend on each other, so change them as a set. Most current Linux packages use the <strong>event<\/strong> MPM. Run <code>apachectl -V | grep -i mpm<\/code> to check which MPM your server uses. A typical event MPM block looks like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">IfModule<\/span> <span class=\"hljs-attr\">mpm_event_module<\/span>&gt;<\/span>\n    StartServers             3\n    MinSpareThreads         75\n    MaxSpareThreads        250\n    ThreadLimit             64\n    ThreadsPerChild         25\n    ServerLimit             16\n    MaxRequestWorkers      400\n    MaxConnectionsPerChild   0\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">IfModule<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>MaxRequestWorkers<\/code> is the maximum number of requests served at the same time. With threaded MPMs it must not exceed <code>ServerLimit<\/code> \u00d7 <code>ThreadsPerChild<\/code> (here 16 \u00d7 25 = 400).<\/li>\n\n\n<li><code>ThreadsPerChild<\/code> cannot be higher than <code>ThreadLimit<\/code>. Changes to <code>ServerLimit<\/code> and <code>ThreadLimit<\/code> need a full restart, not a graceful reload.<\/li>\n\n\n<li><code>MaxConnectionsPerChild 0<\/code> means child processes are never recycled. Set a value such as 10000 if a module leaks memory.<\/li>\n\n\n<li>With prefork (often needed for non-thread-safe mod_php setups), use <code>MinSpareServers<\/code> and <code>MaxSpareServers<\/code>. Size <code>MaxRequestWorkers<\/code> so that it multiplied by the average process memory fits in RAM.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If the error log shows <code>server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting<\/code>, requests are queuing. Raise the limit only if you have spare CPU and memory. Otherwise, look at slow backends and the <code>KeepAliveTimeout<\/code> value first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Replacing legacy and deprecated directives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The legacy section above is not complete, and some entries elsewhere in the list are deprecated without saying so. Use this table when you migrate older configurations to Apache 2.4.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Legacy directive<\/th><th>Status in 2.4<\/th><th>Replacement<\/th><\/tr><\/thead><tbody><tr><td><code>Order<\/code>, <code>Allow<\/code>, <code>Deny<\/code><\/td><td>Work only if mod_access_compat is loaded<\/td><td><code>Require all granted<\/code>, <code>Require all denied<\/code>, <code>Require ip 10.0.0.0\/8<\/code>, <code>Require host example.com<\/code><\/td><\/tr><tr><td><code>NameVirtualHost<\/code><\/td><td>Has no effect and logs a warning<\/td><td>Delete it. Name-based vhosts are automatic.<\/td><\/tr><tr><td><code>MaxClients<\/code><\/td><td>Old name still accepted<\/td><td><code>MaxRequestWorkers<\/code><\/td><\/tr><tr><td><code>MaxRequestsPerChild<\/code><\/td><td>Old name still accepted<\/td><td><code>MaxConnectionsPerChild<\/code><\/td><\/tr><tr><td><code>AddModule<\/code><\/td><td>Removed back in Apache 2.0<\/td><td><code>LoadModule<\/code> only<\/td><\/tr><tr><td><code>SSLCertificateChainFile<\/code><\/td><td>Deprecated since 2.4.8<\/td><td>Put the certificate and its intermediates in the file named by <code>SSLCertificateFile<\/code><\/td><\/tr><tr><td><code>DefaultType<\/code><\/td><td>Only the value <code>none<\/code> is allowed<\/td><td><code>ForceType<\/code> or <code>AddType<\/code>, or a correct <code>TypesConfig<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Apache 2.2 style<\/span>\nOrder deny,allow\nDeny from all\nAllow from <span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.1<\/span><span class=\"hljs-number\">.0<\/span>\/<span class=\"hljs-number\">24<\/span>\n\n<span class=\"hljs-comment\"># Apache 2.4 equivalent<\/span>\n<span class=\"hljs-keyword\">Require<\/span> ip <span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.1<\/span><span class=\"hljs-number\">.0<\/span>\/<span class=\"hljs-number\">24<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Do not mix <code>Order\/Allow\/Deny<\/code> and <code>Require<\/code> in the same context. Their interaction is confusing and often produces <code>client denied by server configuration<\/code> errors. Convert everything to <code>Require<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Inspecting and testing the configuration on your server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>apachectl -L<\/code> command shown above lists only the directives from modules <strong>compiled into<\/strong> the binary. Modules loaded with <code>LoadModule<\/code>, which is how most distribution packages ship mod_ssl, mod_proxy and mod_rewrite, do not appear. Use the commands below to see what your running configuration actually uses. On Debian and Ubuntu, use <code>apache2ctl<\/code> and <code>apache2<\/code> instead of <code>httpd<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Check syntax before every reload (prints \"Syntax OK\")<\/span>\nsudo apachectl configtest\n\n<span class=\"hljs-comment\"># Show loaded modules, both static and shared<\/span>\nsudo apachectl -M\n\n<span class=\"hljs-comment\"># Show which vhost answers which name and port<\/span>\nsudo apachectl -S\n\n<span class=\"hljs-comment\"># Show version, MPM and compiled-in paths<\/span>\napachectl -V\n\n<span class=\"hljs-comment\"># Apply changes without dropping active connections<\/span>\nsudo apachectl -k graceful\n<span class=\"hljs-comment\"># or: sudo systemctl reload httpd   (apache2 on Debian\/Ubuntu)<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><code>apachectl -S<\/code> is the fastest way to debug virtual host problems. It shows the default vhost for each address and port and the file and line where each vhost is defined.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>Invalid command &#039;ProxyPass&#039;, perhaps misspelled...<\/code><\/td><td>The module that provides the directive is not loaded<\/td><td>Load it: <code>a2enmod proxy proxy_http<\/code>, or add the <code>LoadModule<\/code> line<\/td><\/tr><tr><td><code>Could not reliably determine the server&#039;s fully qualified domain name<\/code><\/td><td>No global <code>ServerName<\/code><\/td><td>Add <code>ServerName your.host.name<\/code> at server level<\/td><\/tr><tr><td><code>client denied by server configuration<\/code><\/td><td>No <code>Require all granted<\/code> for the path, or mixed legacy and new access rules<\/td><td>Add a <code>Require<\/code> rule in the matching <code>&lt;Directory&gt;<\/code><\/td><\/tr><tr><td><code>could not bind to address 0.0.0.0:80<\/code><\/td><td>Duplicate <code>Listen<\/code> line or another process using the port<\/td><td>Remove the duplicate; check the port with <code>ss -ltnp<\/code><\/td><\/tr><tr><td><code>NameVirtualHost has no effect...<\/code><\/td><td>Leftover 2.2 directive<\/td><td>Delete the line<\/td><\/tr><tr><td>Wrong site served for a domain<\/td><td><code>ServerName<\/code>\/<code>ServerAlias<\/code> mismatch; the first vhost acts as the default<\/td><td>Check with <code>apachectl -S<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Security baseline directives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These server-level settings are a reasonable hardened starting point for most deployments:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">ServerTokens Prod\nServerSignature Off\nTraceEnable Off\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">Directory<\/span> \/&gt;<\/span>\n    Options None\n    AllowOverride None\n    Require all denied\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">Directory<\/span>&gt;<\/span>\n\nSSLProtocol all -SSLv3 -TLSv1 -TLSv1.1\nSSLHonorCipherOrder off\n\nLimitRequestBody 10485760<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><code>ServerTokens Prod<\/code> reduces the <code>Server<\/code> header to just <code>Apache<\/code>, and <code>ServerSignature Off<\/code> removes the version footer from error pages.<\/li>\n\n\n<li>Denying <code>\/<\/code> and then granting access only to your <code>DocumentRoot<\/code> directories stops Apache from serving files you did not mean to publish.<\/li>\n\n\n<li><code>TraceEnable Off<\/code> disables the HTTP TRACE method, which is rarely needed.<\/li>\n\n\n<li><code>LimitRequestBody<\/code> caps request bodies (10 MB here). Raise it for upload endpoints inside a specific <code>&lt;Location&gt;<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Where is the Apache configuration file located?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On RHEL, Rocky and Fedora it is <code>\/etc\/httpd\/conf\/httpd.conf<\/code>, with extra files in <code>conf.d\/<\/code> and <code>conf.modules.d\/<\/code>. On Debian and Ubuntu it is <code>\/etc\/apache2\/apache2.conf<\/code>, with sites in <code>sites-available\/<\/code> and <code>sites-enabled\/<\/code>. Run <code>apachectl -V<\/code> and look at <code>HTTPD_ROOT<\/code> and <code>SERVER_CONFIG_FILE<\/code> to confirm.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does apachectl -L not show SSL or proxy directives?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>-L<\/code> option lists only directives from modules compiled into the binary. Modules loaded with <code>LoadModule<\/code>, such as mod_ssl and mod_proxy on most distributions, are not included. Use <code>apachectl -M<\/code> to see the loaded modules and the official directive index for their directives.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Is NameVirtualHost still needed in Apache 2.4?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Since 2.4, name-based virtual hosting works automatically for any address and port that has more than one <code>&lt;VirtualHost&gt;<\/code>. The directive has no effect and only causes a warning, so remove it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Should I use .htaccess or the main configuration?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use the main configuration or vhost files whenever you can, and set <code>AllowOverride None<\/code>. Apache then does not have to check for <code>.htaccess<\/code> files on every request, and the rules stay in one reviewed place. Use <code>.htaccess<\/code> only when users cannot edit the server configuration, such as on shared hosting.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need a restart or a reload after changing directives?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Most changes take effect with a graceful reload (<code>apachectl -k graceful<\/code> or <code>systemctl reload<\/code>). Changes to <code>ServerLimit<\/code> and <code>ThreadLimit<\/code> need a full restart. Run <code>apachectl configtest<\/code> first in either case.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/networking\/\">More Networking tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/network-engineer-role-blueprint-responsibilities-skills-kpis-and-career-path\/\">Network Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This page lists the Apache HTTP Server 2.4 configuration directives you will see most often in httpd.conf, virtual host files and SSL configs, grouped by function. Below&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[541],"tags":[13520],"class_list":["post-50437","post","type-post","status-publish","format-standard","hentry","category-networking","tag-apache-http-server"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/50437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=50437"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/50437\/revisions"}],"predecessor-version":[{"id":80182,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/50437\/revisions\/80182"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=50437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=50437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=50437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}