Nginx the browser local cache and virtual machine settings in the server _nginx

Source: Internet
Author: User

To automatically list directory configurations:

Download the open source software are aware that a very simple page lists all the versions of the source code, which is to open the automatic listing directory

The following configuration, in the virtual host location/{...} Configure automatic listing of directories in directory control:

Location/{
  autoindex on;
}

Browser Local Cache settings:

The browser is to speed up browsing, the browser on the user's disk to the most recently requested file storage, when the visitor again request this page,

Browsers can display files from local disks to speed up browsing, save network resources and improve network efficiency

Keywords: expires

Default value: Off

Scope: Http,server.location

Purpose: To control the header information of "Expires" and "Cache-control" in HTTP responses via Expires instruction

Configuration items:


Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $
    {
        expires 30d;
    }
 
    Location ~. *\. (JS|CSS)? $
    {
        expires 1h;
    }


To Configure a virtual host:

Nginx can be configured with multiple types of virtual hosts, ip-based, based on a domain based port,

A simple saying is that different IP same port, different port same IP or domain name, different domain name same port

The following is a virtual host configuration file based on the same domain name:


server {Listen default;
 
    server_name www.wpython.com;
 
    Index index.html index.htm index.php;
 
    root/alidata/www/www.wpython.com;
    # wordpress Pseudo-Static rule location/{if (-F $request _filename/index.html) {rewrite (. *) $1/index.html break;
    } if (f $request _filename/index.php) {rewrite (. *) $1/index.php;
    } if (!-f $request _filename) {rewrite (. *)/index.php;
 
 
    } rewrite/wp-admin$ $scheme://$host $uri/permanent; Location ~. *\.
        (PHP|PHP5) $ {fastcgi_pass 127.0.0.1:9000;
        Fastcgi_index index.php;
    Include fastcgi.conf; } location ~. *\.
    (gif|jpg|jpeg|png|bmp|swf) $ {expires 30d; } location ~. *\.
    (JS|CSS)? $ {Expires 1h;
} Access_log/alidata/log/nginx/access/www.wpython.com.log;
 
    server {Listen default;
 
    server_name www.pyyw.net;
 
    Index index.html index.htm index.php; Root/alidata/www/wwW.pyyw.net;
    # wordpress Pseudo-Static rule location/{if (-F $request _filename/index.html) {rewrite (. *) $1/index.html break;
    } if (f $request _filename/index.php) {rewrite (. *) $1/index.php;
    } if (!-f $request _filename) {rewrite (. *)/index.php;
 
 
    } rewrite/wp-admin$ $scheme://$host $uri/permanent; Location ~. *\.
        (PHP|PHP5) $ {fastcgi_pass 127.0.0.1:9000;
        Fastcgi_index index.php;
    Include fastcgi.conf; } location ~. *\.
    (gif|jpg|jpeg|png|bmp|swf) $ {expires 30d; } location ~. *\.
    (JS|CSS)? $ {Expires 1h;
} Access_log/alidata/log/nginx/access/www.pyyw.net.log;
 }

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.