Windows Nginxhttp Server Getting Started tutorial primary _win server

Source: Internet
Author: User
Introduction Nginx is a very lightweight HTTP server written by the Russians, Nginx, which is pronounced "engine X", is a high-performance http and reverse proxy server, but also a IMAP/POP3/SMTP proxy server.
Second, location grammatical grammar: location [=|~|~*|^~]/uri/{...}
Note:
1, ~ to match case matching
2, ~* for case-insensitive matching
3,!~ and!~* respectively for case-sensitive mismatches and case-insensitive mismatches
Example one:
Location/{}
Matches any query because all requests start with/. However, regular expression rules are matched by precedence and query.
Example two:
Location =/{}
Match only/
Example three:
Copy Code code as follows:

Location ~* \. (Gif|jpg|jpeg) $ {
Rewrite \. (gif|jpg) $/logo.png;


Note: Case-insensitive matches any file ending with Gif,jpg,jpeg
Third, rewrite grammar
Last-basically all with this flag.
Break-Abort Rewirte, no continue match
Redirect-returns the temporarily redirected HTTP status 302
Permanent-Returns HTTP status for permanent redirection 301
1. The following are the expressions that you can use to determine:
-F and!-f are used to determine whether a file exists
-D and!-d used to determine whether a directory exists
-E and!-e used to determine whether a file or directory exists
-X and!-x are used to determine whether a file is executable
2, the following is a global variable that can be used as a judgment
Example: http://localhost:88/test1/test2/test.php
Copy Code code 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

Four, redirect grammar
Copy Code code as follows:

server {
Listen 80;
server_name start.igrow.cn;
Index index.html index.php;
root HTML;
if ($http _host!~ "^star\.igrow\.cn$" [click the picture to open in a new window] {
Rewrite ^ (. *) http://star.igrow.cn$1 redirect;
}
}

Five, anti-theft chain
Copy Code code as follows:

Location ~* \. (gif|jpg|swf) $ {
Valid_referers none blocked start.igrow.cn sta.igrow.cn;
if ($invalid _referer) {
Rewrite ^/http://$host/logo.png;
}
}

Set expiration time based on file type
Copy Code code as follows:

Location ~* \. (js|css|jpg|jpeg|gif|png|swf) $ {
if (-f $request _filename) {
Expires 1h;
Break
}
}

Seven, prohibit access to a directory
Copy Code code 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.