Question

opitmizing nginx on ubuntu 14.04

  • Posted on December 10, 2014
  • newbieAsked by newbie

Hello, i couldn’t find any tutorial for nginx optimization on ubuntu 14.04 unless this one which is for debian actually. https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration

so i replace codes in my nginx configuration (/etc/nginx/nginx.conf) like this way. could someone confirm i have done it correct or should i change any value as im on the smallest droplet package and installed wordpress (512mb).

please check the bottom part. im actually confused with those 2 http heads

i really appreciate your help guy’s

user www-data;
worker_processes 1;
pid /run/nginx.pid;

events {
worker_connections 1024;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log off;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 2;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

# snipping other settings for brevity.

#...
client_max_body_size 8m;
#...
}

#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

http {

# snipping other settings for brevity.

client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
}

http {

# client body buffer.

client_body_buffer_size 10K;
client_header_buffer_size 1k;
large_client_header_buffers 2 1k;
}

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

While the article “How To Optimize Nginx Configuration” was written with Debian in mind, the advice it gives is pretty general and should apply on Ubuntu as well.

Looking at your configuration file above, the one thing that jumps out is that you have multiple http blocks. You should consolidate them by putting every thing that is in a section like:

http {

}

in the same section. Having multiple http blocks could lead to unexpected behavior.