测试版本库,随便折腾。
陈炜
2022-09-26 f8dec7fadcf4f1085f1110003c1150484e56f4c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
 
#user  nobody;
worker_processes  1;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    server_tokens        off;
    sendfile        on;
    #tcp_nopush     on;
    client_max_body_size 5m;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
 
server {
        listen 80 default_server;
        listen 8888 default_server;
        server_name  _;
        return 444;
    }
 
    server {
        listen       8888;
        server_name  oa.shiyi.tv oa.brawin.cn;
        #强制转HTTPS
        #rewrite ^(.*)$  https://$host$1 permanent;
 
        #强制域名访问
#   if ($host != oa.shiyi.tv) {
#            return 403;
#           }
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        #禁止Scrapy等爬虫工具的抓取,如果用到百度收录,这里就要注释掉
        if ($http_user_agent ~* "Scrapy|Sogou web spider|Baiduspider") {
            return 403;
            }
 
        #禁止指定UA及UA为空的访问
        if ($http_user_agent ~ "FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|LinkpadBot|Ezooms|^$"){
            return 403;
            }
 
        #禁止非GET|HEAD|POST方式的抓取,此处可能会导致网页打不开
        #if ($request_method !~ A(GET|HEAD|POST)$) {
        #    return 403;
        #   }
 
        #针对特殊的user_agent的访问
        if ($http_user_agent ~ "Mozilla/4.0\ \(compatible;\ MSIE\ 6.;\ Windows\ NT\ 5.1;\ SV1;\ .NET\ CLR\ 1.1.4322;\ .NET\ CLR\ 2.0.50727\)") {
            return 404;
        }
 
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #proxy_set_header Host $host;
        proxy_set_header Upgrade-Insecure-Requests 1;
        proxy_set_header X-Forwarded-Proto https;
        proxy_read_timeout 300;
 
        location / {
            root   html;
            index  index.html index.htm;
        proxy_pass http://192.168.1.91:80;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
 
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
    }
 
        server {
        listen       80;
        server_name  oa.shiyi.tv oa.brawin.cn;
        #强制转HTTPS
        #rewrite ^(.*)$  https://$host$1 permanent;
 
        #强制域名访问
#   if ($host != oa.shiyi.tv) {
#            return 403;
#           }
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        #禁止Scrapy等爬虫工具的抓取,如果用到百度收录,这里就要注释掉
        if ($http_user_agent ~* "Scrapy|Sogou web spider|Baiduspider") {
            return 403;
            }
 
        #禁止指定UA及UA为空的访问
        if ($http_user_agent ~ "FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|LinkpadBot|Ezooms|^$"){
            return 403;
            }
 
        #禁止非GET|HEAD|POST方式的抓取,此处可能会导致网页打不开
        #if ($request_method !~ A(GET|HEAD|POST)$) {
        #    return 403;
        #   }
 
        #针对特殊的user_agent的访问
        if ($http_user_agent ~ "Mozilla/4.0\ \(compatible;\ MSIE\ 6.;\ Windows\ NT\ 5.1;\ SV1;\ .NET\ CLR\ 1.1.4322;\ .NET\ CLR\ 2.0.50727\)") {
            return 404;
        }
 
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #proxy_set_header Host $host;
        proxy_set_header Upgrade-Insecure-Requests 1;
        proxy_set_header X-Forwarded-Proto https;
        proxy_read_timeout 300;
 
        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://192.168.1.91:80;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
 
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
    }
 
}