Setting up Nginx to serve static data

Now that you are more proficient in installing, configuring, and managing Nginx, we can proceed with some practical questions. Let's see how we can set up Nginx to serve static data such as images, CSS, or JavaScript files.

First, we will take the sample configuration from the previous chapter and make it support multiple virtual hosts using wild card inclusion:

error_log  logs/error.log;

worker_processes 8;

events {
    use epoll;
    worker_connections  10000;
}

http {
    include           mime.types;
    default_type      application/octet-stream;

    include /etc/nginx/site-enabled/*.conf;
}

We have set up Nginx to take advantage of eight processor cores and include all configurations files located in /etc/nginx/site-enabled.

Next, we will configure ...

Get Nginx Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.