Optimizing Nginx in VPS Low Specifications on Linux
This time I will give you tips and tricks on How to optimize the use of the VPS Nginx, which has a lower specification or small. I'm doing this practice on a VPS in Digital Ocean with specifications Single-Core with 512 MB RAM.
![]() |
| Nginx |
Let's start, first check CPU you use, how many cores?
$ grep ^processor /proc/cpuinfo | wc -l
If you only have one, then:
worker_processes 1;
Set up like this, for example as many as 1024 client connections per second:
worker_connections 1024;
BUFFER
Then go to Buffer problem handling, use the following settings:
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 2 1k;
Description of the above settings as follows:
client_body_buffer_size:
It handles POST sent to Nginx.
client_header_buffer_size:
To handle header that requested by the client.
client_max_body_size:
The maximum allowable size of the client request. If you exceed the limit, then Nginx will display the error 413 or "Request Entity Too Large".
large_client_header_buffers:
The maximum size of the buffer for client headers.
TIMEOUT
Then go to the timeout settings.
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
GZIP
Use the settings below:
gzip on;
gzip_comp_level 3;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/x-javascript text/xml text/css application/xml;
I arranged gzip_comp_level only give the value 3, why? because this is a safe setting to a small VPS users. Please note gzip is indeed functions to compress our site to access from the browser to be faster, the greater the level the better because the size will be smaller, but makes the load on the server increases, therefore do not be too big level for your user server or small VPS.
ACCESS LOG
The latter in fact only optional, if you do not need an access log.
access_log off;
If all settings are done, do not forget to check first with the command:
nginx -t
If there is no problem with it, restart your Nginx, so that the configuration runs as it should.
$ sudo service nginx restart
$ sudo systemctl restart nginx
Maybe Useful, if you are confused please comment below.
loading...
loading...

Comments
Post a Comment