How to get started with nginxhttp server in Windows

Source: Internet
Author: User

I. Introduction nginx is a very lightweight HTTP server compiled by Russians. nginx is pronounced as "engine X" and is a high-performance HTTP and reverse proxy server, it is also an IMAP/POP3/SMTP proxy server.
Ii. Location Syntax: Location [= | ~ | ~ * | ^ ~] /Uri /{... }
Note:
1 ,~ Case-sensitive matching
2 ,~ * Case-insensitive match
3 ,!~ And !~ * Case-insensitive and case-insensitive
Example 1:
Location /{}
Match any query because all requests start. However, regular expression rules are preferentially matched with queries.
Example 2:
Location = /{}
Match only/
Example 3: CopyCode The Code is as follows: Location ~ * \. (GIF | JPG | JPEG) $ {
Rewrite \. (GIF | JPG) $/logo.png;
}

Note: case-insensitive matching of any file ending with GIF, JPG, and JPEG
Iii. Rewrite syntax
Last-this flag is basically used.
Break-Abort rewirte and do not continue matching
Redirect-return the HTTP status 302 of the temporary redirect
Permanent-returns the HTTP status 301 for permanent redirection
1. the following expressions can be used to judge:
-F and! -F is used to determine whether a file exists.
-D and! -D is used to determine whether a directory exists.
-E and! -E is used to determine whether a file or directory exists.
-X and! -X is used to determine whether a file is executable.
2. The following are global variables that can be used for judgment.
Example: http: // localhost: 88/test1/Test2/test. phpCopy codeThe Code is as follows: $ HOST: localhost
$ Server_port: 88
$ Request_uri: http: // localhost: 88/test1/Test2/test. php
$ Document_uri:/test1/Test2/test. php
$ Document_root: D: \ nginx/html
$ Request_filename: D: \ nginx/html/test1/Test2/test. php

Iv. Redirect syntaxCopy codeThe Code is as follows: Server {
Listen 80;
SERVER_NAME start.igrow.cn;
Index index.html index. php;
Root HTML;
If ($ http_host !~ "^ Star \. igrow \. cn $ & quot [click an image to open it in a new window] {
Rewrite ^ (. *) http://star.igrow.cn $1 redirect;
}
}

5. Anti-leechCopy codeThe Code is as follows: Location ~ * \. (GIF | JPG | SWF) $ {
Valid_referers none blocked start.igrow.cn sta.igrow.cn;
If ($ invalid_referer ){
Rewrite ^/http: // $ host/logo.png;
}
}

6. Set the expiration time based on the file typeCopy codeThe Code is as follows: Location ~ * \. (JS | CSS | JPG | JPEG | GIF | PNG | SWF) $ {
If (-F $ request_filename ){
Expires 1 h;
Break;
}
}

7. Prohibit Access to a directory copy Code the code is as follows: Location ~ * \. (Txt | DOC) $ {
root/data/www/linuxtone/test;
deny all;
}

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.