Configuring the Nginx Web Server
ServBay offers a convenient way to manage and configure its integrated Nginx web server package. Using ServBay’s intuitive graphical user interface, you can effortlessly adjust Nginx’s core settings to fit the requirements of different local development projects.
Accessing Nginx Configuration
- Open the ServBay application.
- In the left navigation bar, click on
Web Server
. - Select the
Nginx
tab.
You will see the Nginx configuration interface as shown below:
Detailed Explanation of Main Configuration Options
Below is a detailed explanation of each parameter you’ll find in the Nginx configuration interface:
Basic Network Settings
- HTTP Port: The port Nginx listens on for HTTP traffic, default is
80
. - HTTPS Port: The port Nginx listens on for HTTPS traffic, default is
443
. - Worker Connections: The maximum number of simultaneous connections each Nginx worker process can handle. This value affects Nginx’s concurrency capacity.
10240
is a relatively high value suitable for high-traffic scenarios.
Performance & Limits
- Client Max Body Size: The maximum allowed size for the client request body. For example, this limits the maximum upload file size.
2048m
means a maximum request size of 2GB is allowed. - KeepAlive Timeout: The timeout (in seconds) for a Keep-Alive connection between the client and the server.
65
seconds means if the client doesn’t make another request within this period, the server will close the connection. - TCP Nodelay: Enables or disables the
TCP_NODELAY
option. Setting this to On reduces latency for small data packets and is usually recommended for high-latency networks or applications requiring real-time interaction.
HTTP Protocol Versions
- HTTP/2: Enables or disables support for the HTTP/2 protocol. HTTP/2 leverages features like multiplexing and header compression to enhance performance. It is highly recommended to enable this option.
- HTTP/3: Enables or disables support for the HTTP/3 (QUIC) protocol. HTTP/3 is the next-generation protocol, built on UDP, and further improves performance and reliability. Enable this if your version of ServBay supports it and your application requires it.
FastCGI Settings (for PHP and Other Backends)
- FastCGI Connect Timeout: The timeout (in seconds) Nginx waits while attempting to connect to a FastCGI server (like PHP-FPM).
- FastCGI Send Timeout: The timeout (in seconds) for sending a request from Nginx to the FastCGI server.
- FastCGI Read Timeout: The timeout (in seconds) Nginx waits to receive a response from the FastCGI server.
These timeout settings are crucial for handling long-running PHP scripts and should be adjusted based on your application's needs to avoid premature request terminations.
Gzip Compression
- Gzip: Enables or disables Gzip compression. When enabled, Nginx compresses responses before sending them to clients, reducing bandwidth and speeding up page loading times. Enabling this is strongly recommended.
- Gzip Comp Level: The Gzip compression level, ranging from
1
(fastest, lowest compression) to9
(slowest, highest compression).1
or2
usually offers an ideal balance between speed and compression ratio. - Gzip Types: Specifies the content (MIME) types to compress with Gzip. By default, common text, CSS, JavaScript, XML, and RSS types are included. You can add or remove types as needed.
SSL/TLS Settings (for HTTPS)
- SSL Protocols: Defines the SSL/TLS protocol versions allowed.
TLSv1.2 TLSv1.3
are currently the recommended secure settings, disabling legacy insecure protocols such as SSLv3, TLSv1.0, and TLSv1.1. - SSL Prefer Server Ciphers: When enabled (On), the server's own cipher list is given preference over the client's during the SSL/TLS handshake. Enabling this helps ensure stronger encryption algorithms are used and is recommended for security.
- SSL Ciphers: Sets the list of cipher suites the server allows. Using strong, modern cipher suites is essential for HTTPS security. ServBay provides an optimized default list.
Other Settings
- Server Tokens: Controls whether Nginx discloses its version in error pages and the
Server
response header.On
displays the full Nginx version, whileOff
shows onlynginx
. Hiding the exact version is generally considered safer. - Index: Sets the default index file names Nginx looks for when a request points to a directory. For example, with
index.html index.htm index.php
, Nginx will check forindex.html
first; if it's not present, it'll look forindex.htm
, and so on.
Saving and Resetting
- Reset: Clicking this button will restore all Nginx configuration settings to ServBay’s defaults.
- Save: Clicking this button saves all changes made to the Nginx configuration. After saving, ServBay usually applies these changes automatically. If the Nginx service is running, you may need to restart it briefly for changes to take effect.
Important Notes
- The options here modify Nginx’s global configuration (the
http
block withinnginx.conf
). Settings for specific sites (server blocks or virtual hosts)—such asserver_name
,root
, orlocation
rules—are typically configured when adding or editingWebsites
. - If you see a message at the bottom of the configuration interface stating "Service Nginx is not enabled," it means the Nginx service is currently not running. You can still modify and save configuration changes, but they will only take effect the next time you start the Nginx service. You can start Nginx from ServBay’s main panel or via the
Packages
menu.
Conclusion
ServBay streamlines the process of configuring the Nginx web server, allowing developers to easily adjust critical parameters through a visual interface. By understanding and configuring these options, you can optimize Nginx’s performance, security, and functionality—making it better suited for your local web development workflow.