Configure Nginx server display random home and blank picture method _nginx

Source: Internet
Author: User
Tags nginx server

Display Random Home module (Random Index)
in general, a site is the default home page is defined index.html, index.shtml, index.php, and so on, if you want to site there are a lot of pages want to display randomly to the user browsing, the program to achieve, it seems particularly troublesome, if you installed the Nginx, Then use the Nginx Random index can achieve this function, usually/end of the request, will randomly display the current directory of files as the home page.
Random Index Introduction
The Ngx_http_random_index_module module handles requests with a '/' suffix and randomly extracts a page as the homepage in the current directory. This module will be executed before the Ngx_http_index_module module. By default, this module is not installed and you will need to add configuration parameters--with-http_random_index_module when installing Nginx.
Random Home configuration

Location/{
 random_index on;
 }

Random index directive
Syntax: Random_index on | Off
Default value: Random_index off;
Configuration segment: Location
Enable or disable the random index module


generate a blank picture (Empty_gif module)
use Baidu statistics Brother has not noticed that Baidu use 1x1 blank picture Pass statistical parameters, do their own asynchronous statistics brother whether using static file to pass parameters. Why use a blank picture, instead of storing a small map of their own, nginx inside the blank picture is kept in memory, the speed is absolutely faster than the hard disk read. See how you can use Empty_gif to generate a blank picture of the response 1x1.
Nginx default built-in Ngx_http_empty_gif_module module, how to install Nginx I'm not talking more. Look directly at the use of empty_gif
Nginx Configuration
The Nginx module Ngx_http_empty_gif_module will respond to 1x1 gif images.

Location =/_.gif {
    empty_gif;
}

The following is my Nginx configuration

server {
 
    listen    ;
    server_name test.ttlsa.com;
    Access_log/data/logs/nginx/test.ttlsa.com.access.log main;
 
    Index index.html index.php index.html;
    root/data/site/test.ttlsa.com;
 
    Location ~*/3145/
    {
      empty_gif;
    }
}

Test Empty_gif
The results of the access test.ttlsa.com/3145/are as follows:

Empty_gif instruction
Syntax:     empty_gif
Default:     -
Configuration Segment:      Location
Open response 1x1 blank picture
finally
Empty_gif use the most places or statistics, of course, you think you can use the place is also available, as long as you need, after all, memory speed than hard drive is much faster.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.