Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
Great tutorial! Useful and well-written.
One thing: It’s good practice to test your configuration changes after making them, before restarting nginx so perhaps add one final step before “service nginx restart” to recommend the user enter “nginx -t” to make sure there are no typos etc in your configuration changes.
Also need to know which version you use. Because all your setting have directive error.
nginx 1.1.19
@vartanjean7 The stable version of nginx is now 1.6, and the mainline version is at 1.7. If you’re using 1.1.x in mid-2014, you should upgrade your package. (Those directive errors are because you are using very outdated software.)
Why is Debian listed as a requirement? Wouldn’t these configurations be applicable to an Ubuntu installation?
@gustavojimenez.folta: The paths to some configuration files might differ from Ubuntu to Debian but since Ubuntu is based on Debian you should be fine following this tutorial on an Ubuntu system.
Thank you. I wondered because a lot of the configurations aren’t present in my nginx.conf and I wasn’t sure where to place things like client_body_buffer_size, etc.
Having a look here gave me a better understanding in case anyone else is wondering the same. <a target=“_blank” href=“http://nginx.org/en/docs/http/ngx_http_core_module.html”>http://nginx.org/en/docs/http/ngx_http_core_module.html</a>
Adding the following
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
gives me the following error "location" directive is not allowed here in /etc/nginx/nginx.conf:60.
Am I missing something?
Thanks!
I couldn’t find these lines anywhere in nginx.conf ( I use Ubuntu 14.04):
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
and
client_body_timeout 12;
client_header_timeout 12;
send_timeout 10;
Are those supposed to be in nginx.conf or somewhere else? If so, where do I need to put it exactly within the command lines? Just gotta be sure I’m doing it right. Thanks in advance!
Here is a common.conf I have that you can include in your server blocks to make adding servers easier.
listen 80;
index index.php index.html;
# protect dotfiles
location ~ /\. { deny all; error_log off; log_not_found off; }
# ignore common 404s
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
# case insensitive browser cache for static files
# this is the same list as cloudflare plus extras
location ~* \.(7z|ai|bmp|bz2|class|css|csv|docx?|ejs|eot|eps|flv|gif|gz|html?|ico|jar|jpe?g|js|json|lzh|m4a|m4v|midi?|mov|mp3|mp4|pdf|pict|pls|png|pptx?|ps|psd|rar|rss|rtf|svgz?|swf|tar|tiff?|ttf|txt|wav|webp|woff|xlsx?|zip)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# static folders cache
location ~ /(static|files|wp-content|images)/ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
Also make sure that if you’re using regular expressions in the server_name that you give the original host name to PHP, otherwise $_SERVER['SERVER_NAME'] will be the regular expression!
In the fastcgi_params file:
fastcgi_param SERVER_NAME $host;
**[Tutorial correction]**To avoid error in nginx.conf:
I think access_log off Must be access_log off; (add semicolon)