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 a virtual host static.example.com
for serving static data. The following content goes into the file /etc/nginx/site-enabled/static.example.com.conf
:
server { listen 80; server_name static...