{"id":536,"date":"2021-07-23T12:32:21","date_gmt":"2021-07-23T12:32:21","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/nginx-standalone\/"},"modified":"2021-07-23T12:32:21","modified_gmt":"2021-07-23T12:32:21","slug":"nginx-standalone","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/nginx-standalone\/","title":{"rendered":"NGINX\u00ae Standalone"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>This document refers to NGINX\u00ae functionality when you install the <code>ea-nginx-standalone<\/code> package. This was our original version of NGINX and we renamed that package. For information about the newer, updated <code>ea-nginx<\/code> package, read our NGINX with Reverse Proxy documentation.<\/p>\n<\/p><\/div>\n<\/div>\n<p>This document explains how to install NGINX Standalone on a server that runs cPanel &#038; WHM and EasyApache 4. NGINX is an open source web server that also provides a reverse proxy, load balancing, and caching. It functions very differently from Apache\u00ae. NGINX does <strong>not<\/strong> serve dynamic content unless you pass it through a proxy.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n        NGINX Standalone is <strong>experimental<\/strong>. You <strong>must<\/strong> install the Experimental Repository to use it.\n    <\/div>\n<\/div>\n<h2 id=\"requirements\">Requirements<\/h2>\n<p>To install NGINX on your server, you must meet the following requirements:<\/p>\n<ul>\n<li>\n<p>Run EasyApache 4.<\/p>\n<\/li>\n<li>\n<p>Install the Experimental Repository. Use the following command to install this repository: <\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">yum install ea4-experimental<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Possess <code>root<\/code> user access to the server.<\/p>\n<\/li>\n<li>\n<p>Use PHP-FPM as the server\u2019s PHP handler.<\/p>\n<\/li>\n<li>\n<p>Install the <code>ea-ruby27-mod_passenger<\/code> Apache module. When you install the <code>ea-nginx-standalone<\/code> module, the system will install this module and other necessary Ruby modules if they don\u2019t already exist.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>If your system runs CentO6, install the <code>ea-ruby24-mod_passenger<\/code> Apache module.<\/li>\n<li>Phusion Passenger\u00ae functions the same in both NGINX and Apache.<\/li>\n<\/ul><\/div>\n<\/div>\n<\/li>\n<\/ul>\n<h3 id=\"compatibility\">Compatibility<\/h3>\n<p>NGINX takes the place of Apache as the primary web server. The installation will move Apache away from its default ports in favor of NGINX.<\/p>\n<p>For more information, read the NGINX configuration changes section below.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        You can still use Apache to serve dynamic content, but <strong>must<\/strong> proxy your requests to the server.\n    <\/div>\n<\/div>\n<h2 id=\"install-or-uninstall-nginx\">Install or uninstall NGINX<\/h2>\n<h3 id=\"install\">Install<\/h3>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>If the Experimental Repository does <strong>not<\/strong> already exist on your server, install it with the following command: <\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">yum install ea4-experimental<\/code><\/pre>\n<\/div><\/div>\n<\/div>\n<p>To install NGINX, run the following command on the command line:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">yum --enablerepo<span style=\"color:#f92672\">=<\/span>EA4-experimental install ea-nginx-standalone<\/code><\/pre>\n<\/div>\n<h3 id=\"uninstall\">Uninstall<\/h3>\n<p>To uninstall NGINX, run the following command on the command line:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">yum erase ea-nginx-standalone<\/code><\/pre>\n<\/div>\n<h2 id=\"the-nginx-installation\">The NGINX installation<\/h2>\n<p>When you install cPanel &#038; WHM\u2019s version of NGINX, the installation process will change your server\u2019s Apache installation to use different ports.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        The process will only change your Apache ports if your Apache configuration uses the default ports of <code>80<\/code> and <code>443<\/code>.\n    <\/div>\n<\/div>\n<p>When you install NGINX, the installation process installs the <code>ea-ruby27-mod_passenger<\/code> Apache module. This module is <strong>required<\/strong>.<\/p>\n<p>The following features will work with NGINX without any further action by the user:<\/p>\n<ul>\n<li>\n<p>Static content. <\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        You <strong>must<\/strong> proxy any dynamic content to Apache.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>The MultiPHP system.<\/p>\n<\/li>\n<li>\n<p>WordPress\u00ae installed via WordPress Manager. <\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>\n<p>Installations of WordPress outside of WordPress Manager will not support Pretty Permalinks. For more information, read WordPress\u2019 Pretty Permalinks documentation.<\/p>\n<\/li>\n<li>\n<p>If you do <strong>not<\/strong> wish to manage your WordPress site through WordPress Manager, read the WordPress does not support Pretty Permalinks section below.<\/p>\n<\/li>\n<\/ul><\/div>\n<\/div>\n<\/li>\n<li>\n<p>Mailman.<\/p>\n<\/li>\n<li>\n<p>AutoSSL.<\/p>\n<\/li>\n<li>\n<p>Proxy subdomains and redirects. <\/p>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n        The MultiPHP system and Wordpress will <strong>only<\/strong> work if you use PHP-FPM.\n    <\/div>\n<\/div>\n<\/li>\n<\/ul>\n<h3 id=\"nginx-configuration-changes\">NGINX configuration changes<\/h3>\n<p>When you install NGINX on your server, the installation process makes several changes to your system.<\/p>\n<p>Most notably, the installation configures Apache to no longer act as the primary web server. Because of this, the NGINX installation will create proxies for MailMan and AutoSSL.<\/p>\n<h3 id=\"configuration-files\">Configuration files<\/h3>\n<p>The system creates the <code>\/etc\/nginx\/conf.d\/ea-nginx.conf<\/code> configuration file.<\/p>\n<h4 id=\"custom-configurations\">Custom configurations<\/h4>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>\n<p>Do <strong>not<\/strong> edit any of the files that NGINX owns. Changing these files may result in unexpected behavior.<\/p>\n<\/li>\n<li>\n<p>If you create custom configuration files, you may change NGINX behavior in undesired ways. For example, if your custom block matches the PHP block, the server may serve the source code instead of PHP.<\/p>\n<\/li>\n<\/ul><\/div>\n<\/div>\n<p>If you want to customize the server blocks for NGINX, create an include file that ends in <code>.conf<\/code> in the appropriate location. A server block is the same thing as a virtual host in Apache.<\/p>\n<p>For more information about server blocks, including examples, read NGINX\u2019s Server Block Examples documentation.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        Do <strong>not<\/strong> use <code>cpanel-<\/code> as the prefix for any custom files you create.\n    <\/div>\n<\/div>\n<h4 id=\"global-configuration\">Global configuration<\/h4>\n<p>Place any global <code>.conf<\/code> files that you create in the <code>\/etc\/nginx\/conf.d\/<\/code> directory.<\/p>\n<p>If you want to adjust every server block on your server, create your <code>.conf<\/code> file in the <code>\/etc\/nginx\/conf.d\/server-includes\/<\/code> directory.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        Make certain that you also reference your <code>.conf<\/code> file with an <code>include<\/code> directive in the file that you want to use it in.\n    <\/div>\n<\/div>\n<h4 id=\"user-configuration\">User configuration<\/h4>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>In the following examples, <code>username<\/code> represents the username, and <code>domainname<\/code> represents the fully-qualified domain name.<\/p>\n<p>This fully-qualified domain name must be one of the following:<\/p>\n<ul>\n<li>\n<p>The server block\u2019s main domain.<\/p>\n<\/li>\n<li>\n<p>The server block\u2019s subdomain for addon domains and their subdomains.<\/p>\n<\/li>\n<li>\n<p>The server block\u2019s subdomain for subdomains that are not addon domains.<\/p>\n<\/li>\n<\/ul><\/div>\n<\/div>\n<p>To customize every server block that a user owns, create your <code>.conf<\/code> file in following directory:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/etc\/nginx\/conf.d\/users\/username<\/code><\/pre>\n<\/div>\n<p>To customize a specific server block for a specific domain, create your <code>.conf<\/code> file in the  following directory:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/etc\/nginx\/conf.d\/users\/username\/domainname\/<\/code><\/pre>\n<\/div>\n<h4 id=\"apache-configuration\">Apache configuration<\/h4>\n<p>The NGINX installation makes the following changes to your Apache configuration:<\/p>\n<ul>\n<li>\n<p>Changes the Apache port to the first available port under <code>1024<\/code>. This will usually be port <code>81<\/code>. You must proxy any applications that are not static to Apache.<\/p>\n<\/li>\n<li>\n<p>Changes the Apache SSL port to the first available port under <code>1024<\/code>. This will usually be port <code>444<\/code>. <\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        Your Apache ports will <strong>only<\/strong> change if your configuration uses the default ports <code>80<\/code> and <code>443<\/code>. The installation ignores custom port numbers.\n    <\/div>\n<\/div>\n<\/li>\n<li>\n<p>Adds the following to the <code>\/etc\/nginx\/conf.d\/ea-nginx.conf<\/code> file: <\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">5\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">6\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"color:#66d9ef\">map<\/span> <span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#a6e22e\">host<\/span> <span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#a6e22e\">CPANEL_APACHE_PROXY_IP<\/span> {\n        <span style=\"color:#66d9ef\">default<\/span> <span style=\"color:#ae81ff\">127.0.0.1<\/span>;\n    }  \n<span style=\"color:#66d9ef\">map<\/span> <span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#a6e22e\">host<\/span> <span style=\"color:#960050;background-color:#1e0010\">$<\/span><span style=\"color:#a6e22e\">CPANEL_APACHE_PROXY_PORT<\/span> {\n        <span style=\"color:#66d9ef\">default<\/span> <span style=\"color:#ae81ff\">81<\/span>;\n    }<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<h4 id=\"file-access\">File access<\/h4>\n<p>NGINX does <strong>not<\/strong> serve files that start with <code>.ht<\/code> by default.  There may be other files that you want to restrict access to.<\/p>\n<p>The easiest solution is to <strong>not<\/strong> include restricted-access files in the document root. However, if this is not possible, you can also explicitly restrict access to files.<\/p>\n<p>For example, if you serve your website from a git repository, you may want to prevent access to the site\u2019s <code>.git<\/code> directory.  To do this, create a <code>.conf<\/code> file in the appropriate location and add the following commands to your file:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">5\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">6\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">location ~ \/<span style=\"color:#ae81ff\">.<\/span>git <span style=\"color:#f92672\">{<\/span>\n\t   deny all;\n\t   log_not_found off;\n\t   access_log off;\n\t   <span style=\"color:#66d9ef\">return<\/span> <span style=\"color:#ae81ff\">404<\/span>;\n   <span style=\"color:#f92672\">}<\/span>  <\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>After you save the file, reload your server to activate the configuration change.<\/p>\n<p>For more information, read the NGINX Location Priority documentation.<\/p>\n<h4 id=\"cloudflare\">CloudFlare\u00ae<\/h4>\n<p>The NGINX installation will detect if a domain uses CloudFlare and configure the system to work properly.<\/p>\n<p>The system saves the CloudFlare configuration to the following location:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/etc\/nginx\/conf.d\/includes-optional\/cloudflare.conf<\/code><\/pre>\n<\/div>\n<p>If your secure connections don\u2019t appear in the SSL log, you can change the SSL settings in CloudFlare.<\/p>\n<h3 id=\"log-files\">Log Files<\/h3>\n<p>NGINX rotates logs with the <code>logrotate<\/code> utility. This means that WHM\u2019s <em>cPanel Log Rotation Configuration<\/em> interface (<em>WHM &gt;&gt; Home  &gt;&gt; Service Configuration &gt;&gt; cPanel Log Rotation Configuration<\/em>) will <strong>not<\/strong> affect the NGINX log rotation. This activity will register in your user stats and bandwidth programs.<\/p>\n<p>NGINX uses the cPanel &#038; WHM default Apache log formats. It will <strong>not<\/strong> recognize any custom Apache log formats. You <strong>cannot<\/strong> manage NGINX logs in any interfaces that specifically displays Apache logs, such as WHM\u2019s <em>Log Rotation<\/em> interface (WHM &gt;&gt; Home &gt;&gt; Service Configuration &gt;&gt; Log Rotation_). Apache does <strong>not<\/strong> log any requests that NGINX proxies to it.<\/p>\n<p>NGINX logs traffic for the <code>www<\/code> subdomain to the same location as non-<code>www<\/code> subdomains, which duplicates the Apache behavior. For example, it will log requests for <code>www.example.com<\/code>  and  <code>example.com<\/code>  to the <code>\/var\/log\/nginx\/domains\/example.com<\/code> file.<\/p>\n<p>NGINX uses the same server block for both SSL and non-SSL requests. However, it handles requests differently depending on if you use piped logging or not.<\/p>\n<h4 id=\"piped-logging\">Piped logging<\/h4>\n<p>NGINX saves its log files to the following locations, where <code>domainname<\/code> represents the domain name:<\/p>\n<ul>\n<li>SSL \u2014  <code>\/var\/log\/nginx\/domains\/domainname-ssl_log<\/code><\/li>\n<li>Non-SSL \u2014 <code>\/var\/log\/nginx\/domains\/domainname<\/code><\/li>\n<li>Bandwidth  \u2014 <code>\/var\/log\/nginx\/domains\/domainname-bytes_log<\/code><\/li>\n<\/ul>\n<p>NGINX also logs requests to the following location:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/var\/log\/nginx\/access.log<\/code><\/pre>\n<\/div>\n<h4 id=\"regular-logging\">Regular logging<\/h4>\n<p>Without piped logging, both SSL and non-SSL requests save to the same location. NGINX saves its log files to the following locations, where <code>domainname<\/code> represents the domain name:<\/p>\n<ul>\n<li>SSL and non-SSL \u2014 <code>\/var\/log\/nginx\/domains\/domainname<\/code>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        These files will also contain an extra column at the beginning,  in  <code>domainname:port<\/code> format.\n    <\/div>\n<\/div>\n<\/li>\n<li>Bandwidth \u2014 <code>\/var\/log\/nginx\/domains\/domainname-bytes_log<\/code><\/li>\n<\/ul>\n<h3 id=\"redirects\">Redirects<\/h3>\n<p>NGINX supports proxy subdomains and redirects.<br \/>\nTo create a redirect, use cPanel\u2019s <em>Redirects<\/em>  (<em>Home &gt;&gt; cPanel &gt;&gt; Domains &gt;&gt; Redirects<\/em>) interface. These redirects differ from the Apache redirect behavior in the following ways:<\/p>\n<ul>\n<li>Redirects apply to the whole server block, not the exact fully qualified domain  name (FQDN). If you set a redirect for one domain, it will also effect any other FQDN in the block.<\/li>\n<li>Redirects apply to both the <code>www<\/code> and any non-<code>www<\/code> subdomains, regardless of the behavior in Apache. You can change this behavior with include files.<\/li>\n<li>Redirects do <strong>not<\/strong> change <code>HTTP<\/code> requests to <code>HTTPS<\/code> requests. To enable this behavior, use the <em>Force HTTPS Redirect<\/em>  option in cPanel\u2019s  <em>Domains<\/em> (<em>Home &gt;&gt; cPanel &gt;&gt; Domains &gt;&gt; Domains<\/em>) interface.<\/li>\n<li>Redirects that point to an <code>index.html<\/code> file will also redirect the domain name both with and without a trailing slash. For example, NGINX will redirect both <code>example.com<\/code> and <code>example.com\/<\/code>.\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        If the redirect matches another <code>index<\/code> file first, then it will serve that <code>index<\/code> file.\n    <\/div>\n<\/div>\n<\/li>\n<li>NGINX <strong>only<\/strong> returns the <code>301<\/code> and <code>302<\/code> HTTP status codes.<\/li>\n<\/ul>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        You <strong>cannot<\/strong> use the Safari\u00ae web browser to log in to a service subdomain. Use another browser, or log in with the service\u2019s port URL.\n    <\/div>\n<\/div>\n<h4 id=\"use-include-files-to-change-redirect-behavior\">Use include files to change redirect behavior<\/h4>\n<p>You can use include files to force NGINX to redirect <code>www<\/code> domains to non-<code>www<\/code> domains, and vice versa. You <strong>cannot<\/strong> use these include files for parked domains or to redirect <code>HTTP<\/code> to <code>HTTPS<\/code>.<\/p>\n<p>To do this, we created the following include files. You can create a symlink that points to one of the following files to alter the redirect behavior:<\/p>\n<ul>\n<li><code>\/etc\/nginx\/conf.d\/includes-optional\/force-non-www.conf<\/code><\/li>\n<li><code>\/etc\/nginx\/conf.d\/includes-optional\/force-www.conf<\/code>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>Do <strong>not<\/strong> use both of these files in your symlinks. This will create an infinite loop.<\/li>\n<li>You must run the \/usr\/local\/cpanel\/scripts\/ea-nginx script  command after you create your <code>.conf<\/code> file.<\/li>\n<\/ul><\/div>\n<\/div>\n<\/li>\n<\/ul>\n<p>To set redirect behavior for all of a user\u2019s domains, add the following symlink, where <code>redirect-file<\/code> represents one of the files above and <code>username<\/code> represents the user:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">ln -s redirect-file \/etc\/nginx\/conf.d\/users\/username\/www-behavior.conf<\/code><\/pre>\n<\/div>\n<p>To set redirect behavior for only specific domains, add the following symlink, where <code>redirect-file<\/code> represents one of the files above, <code>username<\/code> represents the user, and <code>domainname<\/code> represents the domain or subdomain:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">ln -s redirect-file \/etc\/nginx\/conf.d\/users\/username\/domainname\/www-behavior.conf<\/code><\/pre>\n<\/div>\n<p>For example, to redirect <code>www.sub.example.com<\/code> to <code>sub.example.com<\/code> you might run the following commands:\n<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">mkdir -p \/etc\/nginx\/conf.d\/users\/myuser\/sub.example.com\nln -s \/etc\/nginx\/conf.d\/includes-optional\/force-non-www.conf \/etc\/nginx\/conf.d\/users\/myuser\/sub.example.com\/non-www-behavior.conf<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<h3 id=\"run-nginx\">Run NGINX<\/h3>\n<p>To stop or restart NGINX, use the <code>\/usr\/local\/cpanel\/scripts\/restartsrv_nginx<\/code> script.<\/p>\n<p>We <strong>strongly<\/strong> recommend that you <strong>only<\/strong> use the cPanel script or WHM\u2019s <em>Service Manager<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Service Configuration &gt;&gt; Service Manager<\/em>) to restart NGINX.<\/p>\n<p>To use the restart commands in CentOS 7 to restart NGINX, you <strong>must<\/strong> use the <code>reload<\/code> option. This option ensures a graceful restart:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">systemctl reload nginx.service<\/code><\/pre>\n<\/div>\n<p>For more information, read our How to Restart Services documentation.<\/p>\n<h3 id=\"configure-a-user\">Configure a user<\/h3>\n<p>In cPanel &#038; WHM version 80 through 84, the system integrates NGINX into your user and domain changes, with the following exceptions:<\/p>\n<ul>\n<li>PHP-FPM Hostname Changes<\/li>\n<li>Piped Log Configuration<\/li>\n<li>Apache log style<\/li>\n<\/ul>\n<p>In cPanel &#038; WHM version 86 and later, the system integrates these changes.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        It may take your NGINX configuration several minutes to update if you make changes to your PHP version or PHP-FPM configuration, enable or disable PHP-FPM, or add WordPress.\n    <\/div>\n<\/div>\n<p>The system uses the \/usr\/local\/cpanel\/scripts\/ea-nginx script to make these changes. You do <strong>not<\/strong> need to run this script.<\/p>\n<p>The system creates the <code>.conf<\/code> file in the following location, where <code>username<\/code> represents the username:\n<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">\/etc\/nginx\/conf.d\/users\/username.conf<\/code><\/pre>\n<\/div>\n<h3 id=\"configure-an-application\">Configure an application<\/h3>\n<p>In cPanel &#038; WHM version 90 and later, you can use cPanel\u2019s <em>Application Manager<\/em> interface (<em>Home &gt;&gt; cPanel &gt;&gt; Software &gt;&gt; Application Manager<\/em>) to configure applications.<\/p>\n<p>In previous version of cPanel &#038; WHM, you must run the \/usr\/local\/cpanel\/scripts\/ea-nginx script to update your configuration and restart the server.<\/p>\n<h2 id=\"limitations\">Limitations<\/h2>\n<p>If one of your domains matches a proxy domain, the system will warn you that it will ignore conflicting duplicate entries. This conflict may result in unexpected behavior.<\/p>\n<div class=\"callout callout-danger\">\n<div class=\"callout-heading\">Warning:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>\n<p>If you use NGINX and ModSecurity\u00ae 2, your ModSecurity rules <strong>only<\/strong> apply when NGINX proxies the request to Apache.<\/p>\n<\/li>\n<li>\n<p>Any restrictions set in an <code>.htaccess<\/code> file will not apply. For example, if you password-protected a directory, the protection will not work.<\/p>\n<\/li>\n<li>\n<p>If you create an alias, make <strong>certain<\/strong> that your path\u2019s location ends with a trailing slash (<code>\/<\/code>). If your path does <strong>not<\/strong> end with a <code>\/<\/code>, then your path is vulnerable to a path traversal exploit.<\/p>\n<\/li>\n<li>\n<p>For more information, read the NGINX Security Advisories documentation.<\/p>\n<\/li>\n<\/ul><\/div>\n<\/div>\n<h2 id=\"troubleshooting\">Troubleshooting<\/h2>\n<h3 id=\"could-not-build-the-server-names-hash\">Could not build the server_names_hash<\/h3>\n<p>You may receive an error that resembles the following message:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-go\" data-lang=\"go\"><span style=\"color:#a6e22e\">could<\/span> <span style=\"color:#a6e22e\">not<\/span> <span style=\"color:#a6e22e\">build<\/span> <span style=\"color:#a6e22e\">the<\/span> <span style=\"color:#a6e22e\">server_names_hash<\/span>,\n<span style=\"color:#a6e22e\">you<\/span> <span style=\"color:#a6e22e\">should<\/span> <span style=\"color:#a6e22e\">increase<\/span> <span style=\"color:#a6e22e\">either<\/span> <span style=\"color:#a6e22e\">server_names_hash_max_size<\/span>: <span style=\"color:#ae81ff\">512<\/span>\n<span style=\"color:#a6e22e\">or<\/span> <span style=\"color:#a6e22e\">server_names_hash_bucket_size<\/span>: <span style=\"color:#ae81ff\">32<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<p>If you receive this error message, increase the value of the following directives in the <code>\/etc\/nginx\/conf.d\/ea-nginx.conf<\/code> and the <code>\/etc\/nginx\/ea-nginx\/settings.json<\/code> files:<\/p>\n<ul>\n<li>\n<p><code>server_names_hash_max_size<\/code><\/p>\n<\/li>\n<li>\n<p><code>server_names_hash_bucket_size<\/code><\/p>\n<\/li>\n<\/ul>\n<p>For more information, read the NGINX Server Names documentation.<\/p>\n<h3 id=\"nginx-will-not-restart\">NGINX will not restart<\/h3>\n<p>If you used the <code>nginx<\/code> command to start NGINX, then the <code>\/usr\/local\/cpanel\/scripts\/restartsrv_nginx<\/code> and <code>systemctl restart nginx.service<\/code> commands will not work. To correct this, perform the following steps:<\/p>\n<ol>\n<li>\n<p>Stop the service with the \/usr\/sbin\/nginx -s stop command.<\/p>\n<\/li>\n<li>\n<p>Restart NGINX with one of the following commands:<\/p>\n<ul>\n<li>\n<p><code>\/usr\/local\/cpanel\/scripts\/restartsrv_nginx start<\/code><\/p>\n<\/li>\n<li>\n<p><code>systemctl start nginx.service<\/code><\/p>\n<\/li>\n<li>\n<p><code>\/etc\/init.d\/nginx start<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3 id=\"wordpress-multisite\">WordPress Multisite<\/h3>\n<p>WordPress Multisite does <strong>not<\/strong> work with cPanel &#038; WHM servers that use nginx.<\/p>\n<h3 id=\"can-t-use-pretty-permalinks-with-wordpress\">Can\u2019t use Pretty Permalinks with WordPress<\/h3>\n<p>Installations of WordPress outside of WordPress Manager will <strong>not<\/strong> support Pretty Permalinks.<\/p>\n<p>To resolve this issue, you <strong>must<\/strong> perform one of the following actions:<\/p>\n<ul>\n<li>\n<p>Manage your WordPress site through WordPress Manager.<\/p>\n<\/li>\n<li>\n<p>Add the following information to your NGINX configuration file, where <code>php73<\/code> represents the version of PHP your server runs and <code>1ed179754201ac2644e8c70140bacb23c7786484<\/code> represents the PHP-FPM socket though which WordPress runs:<\/p>\n<\/li>\n<\/ul>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>\n<p>To obtain the correct PHP-FPM socket, run the following command where <code>username<\/code> represents the username: <\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">awk -F <span style=\"color:#e6db74\">':'<\/span> <span style=\"color:#e6db74\">'\/fastcgi_pass unix\/ {gsub(\/;\/,\"\"); print $2}'<\/span> \/etc\/nginx\/conf.d\/users\/username.conf<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n<p>Be sure to follow the instructions in the Configure a user section of this document so NGINX does not overwrite your changes.<\/p>\n<\/li>\n<\/ul><\/div>\n<\/div>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">5\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">6\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">7\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">8\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-BASH\" data-lang=\"BASH\">location \/wordpress <span style=\"color:#f92672\">{<\/span>\n     try_files $uri $uri\/ \/wordpress\/index.php?$args;\n      location ~ <span style=\"color:#ae81ff\">.<\/span>php7?$ <span style=\"color:#f92672\">{<\/span>\n      include conf.d\/includes-optional\/cpanel-fastcgi.conf;\n      fastcgi_pass unix:\/opt\/cpanel\/ea-php73\/root\/usr\/var\/run\/php-fpm\/1ed179754201ac2644e8c70140bacb23c7786484.sock;\n      error_page <span style=\"color:#ae81ff\">502<\/span> <span style=\"color:#ae81ff\">503<\/span> \/FPM_50x.html;\n  <span style=\"color:#f92672\">}<\/span>\n<span style=\"color:#f92672\">}<\/span><\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview Note: This document refers to NGINX\u00ae functionality when you install the ea-nginx-standalone package. This was our original version of NGINX and we renamed that package. For information about the newer, updated ea-nginx package, read our NGINX with Reverse Proxy documentation. This document explains how to install NGINX Standalone on a server that runs cPanel &hellip;<\/p>\n","protected":false},"author":1,"featured_media":537,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/536"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=536"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/536\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/537"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}