forked from codeskyblue/gohttpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx_example_nossl.conf
72 lines (63 loc) · 2.32 KB
/
nginx_example_nossl.conf
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
#Use Nginx to deploy GoHttpFileServer Example(https://github.com/codeskyblue/gohttpserver)
#Nginx反向代理至GoHttpFileServer的例子
#By h45251880,Tested on windows 10
worker_processes auto;
events {
multi_accept on;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
#优化
#optimization
sendfile on;
tcp_nopush on;
server_tokens off;
tcp_nodelay on;
#开启Gzip
#enable Gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name your_domain; #网域 #domain
#禁止真实ip访问
#ban real ip access
#if ($host != 'your_domain') {
# rewrite ^/(.*)$ http://your_domain/$1 permanent;
#}
#防爬虫、压力、节点测试等等...
#No spider、webbench、ping...
#if ($http_user_agent ~* (Scrapy|Curl|HttpClient)) {
# return 403;
#}
#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;
#}
#if ($request_method !~ ^(GET|HEAD|POST)$) {
# return 403;
#}
#if ($http_user_agent ~* (Wget|ab) ) {
# return 403;
#}
#if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
# return 403;
#}
#设置到GoHttpFileServer
#set to GoHttpFileServer
location / {
proxy_pass http://127.0.0.1:8000; #GoHttpFileServer的端口 #GoHttpFileServer port
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_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0; #disable upload limit
}
}
}