Fortune Telling Collection - Fortune-telling birth date - Use Nginx profile to mask the specified request.
Use Nginx profile to mask the specified request.
1. Masks the request mode, and only allows POST, GET, etc.
When there is a request way to visit the website that we don't allow, define the return 403 status code. The sample configuration is as follows:
if ($request_method! ~ ^(GET|POST)$)
{
Return to 403;
}
2. Define the error page
Sometimes when we visit a non-existent page or report an error, such as 403/404/502/503/504/405, or a program error similar to 500 appears, we hope to jump to a unified error page for security and user-friendliness. You can add the following sample configurations:
error _ page 404 403 502 503/error . html
location = /error.html {
Root html
}
The premise here is to write an error page yourself and put it in the specified nginx server directory.
3. Mask the specified url
For example, when multiple server _ names provided by a nginx share static resources, but there is only one resource that server _ name wants to access; For example, the program is not reasonable enough, and it is found that some addresses should not provide internet access when the production environment is running; Or we want to filter out some malicious access such as special characters through nginx. We can use the following sample configuration to filter the specified url and jump to the error page:
if ( $request_uri ~* "..; | test 1234 | home/test . do "){
Override xxxxxxxxx# or return to specify the error code.
}
The scope can be a server or a location. The above writing method is to use regular matching to the url containing the above string, adjust it according to the usage scenario, escape the use, and separate multiple strings with |.
4. Mask the specified IP address.
For example, when our service only wants to specify that the IP address is accessible or the IP specified after deployment is inaccessible, we can use the following sample configuration to force a jump to the error page.
if ($http_x_forwarded_for! ~ ^( 192. 168.3. 100| 123. 123. 123. 123|222.222.222.222)) {
Return to 403; # or rewrite the specified page.
}
The scope can be server or location.
5. More exotic needs
I have a service, test, which is open to the Internet, but the addresses, such as /test/admin.jsp and /test/config.jsp, only allow a few designated people to access it, and others are not allowed to access it. Here, I use the above 3 and 4 in combination. An example configuration is as follows:
Location/Test {
Set $ flag0;
if($ request _ uri ~ * " admin . JSP | config . JSP "){
Set $ flag "$ {flag}1";
}
if ($http_x_forwarded_for! ~ ^( 192. 168.3. 100| 123. 123. 123. 123|222.222.222.222)) {
Set $ flag "$ {flag} 2";
}
if ( $flag = "0 12" ){
Return to 403;
}
proxy _ pass xxxxxxxxxxxxxxxxx
proxy _ set _ header xxxxxxxxxxxxxxxxxx;
.......................
}
Originally, I thought that if it was true, flag=flag+ 1, but I wrote it casually and found it was wrong, so I changed this familiar string splicing method, and all roads lead to the same goal;
The initial flag is 1. If you visit the specified URL, it will become 0 1. If the URL you visit is not the IP allowed by our white list, the logo will become 0 12. Finally, judge the flag and refuse to visit if it is out of date.
Write at the end:
If there are any mistakes, please comment and let us know. Please forgive me.
Use Nginx profile to screen the specified requested blog _ Von Blog.
- Related articles
- Top ten list of grave robbery novels
- What does Daxian fortune-telling mean by predestination _ What does Daxian fortune-telling mean by predestination?
- The big eunuch finale of TV series
- Besides self-discipline, the way to change your destiny is diet.
- Yue opera fortune-telling video daquan _ Yue opera fortune-telling video daquan
- There is a blind man telling fortune on Nanjing Road. I only told him mine, my father's, my mother's birthday, year, month and day, and he counted me as one.
- Look at the eight characters, suffer from depression, live very tired, who can give some advice?
- Fu Tiehu's name, number of strokes and fortune telling
- Classic words, life sentiment, philosophy, incisive and simple short sentences
- 1977 the fate of women on the first day of the first month