geba123 commited on
Commit
3bb2be6
·
verified ·
1 Parent(s): 10d9b4c

Upload hf_nginx.conf

Browse files
Files changed (1) hide show
  1. hf_nginx.conf +86 -0
hf_nginx.conf ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen 7860;
3
+ server_name localhost;
4
+
5
+ #access_log /var/log/nginx/host.access.log main;
6
+
7
+ resolver 114.114.114.114 8.8.8.8 valid=300s;
8
+ resolver_timeout 5s;
9
+
10
+ # 创建代理路由
11
+ location /proxy/ {
12
+ # 设置CORS头部
13
+ add_header 'Access-Control-Allow-Origin' '*';
14
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
15
+ add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
16
+ add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
17
+
18
+ # OPTIONS请求处理
19
+ if ($request_method = 'OPTIONS') {
20
+ add_header 'Access-Control-Max-Age' 1728000;
21
+ add_header 'Content-Type' 'text/plain charset=UTF-8';
22
+ add_header 'Content-Length' 0;
23
+ return 204;
24
+ }
25
+
26
+ set $target_url '';
27
+
28
+ # 执行Lua脚本解析URL
29
+ rewrite_by_lua_file /usr/share/nginx/html/proxy.lua;
30
+
31
+ proxy_ssl_server_name on;
32
+ proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
33
+
34
+ # 设置代理头信息
35
+ # 不设置Host,让Nginx自动根据目标URL设置
36
+ proxy_set_header X-Real-IP $remote_addr;
37
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38
+ proxy_set_header X-Forwarded-Proto $scheme;
39
+ # 处理可能的重定向
40
+ proxy_redirect off;
41
+ proxy_buffering off;
42
+ # 代理超时设置
43
+ proxy_connect_timeout 60s;
44
+ proxy_send_timeout 60s;
45
+ proxy_read_timeout 60s;
46
+
47
+ proxy_pass $target_url;
48
+ }
49
+
50
+ location / {
51
+ root /usr/share/nginx/html;
52
+ index index.html index.htm;
53
+ }
54
+
55
+ #error_page 404 /404.html;
56
+
57
+ # redirect server error pages to the static page /50x.html
58
+ #
59
+ error_page 500 502 503 504 /50x.html;
60
+ location = /50x.html {
61
+ root /usr/share/nginx/html;
62
+ }
63
+
64
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
65
+ #
66
+ #location ~ \.php$ {
67
+ # proxy_pass http://127.0.0.1;
68
+ #}
69
+
70
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
71
+ #
72
+ #location ~ \.php$ {
73
+ # root html;
74
+ # fastcgi_pass 127.0.0.1:9000;
75
+ # fastcgi_index index.php;
76
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
77
+ # include fastcgi_params;
78
+ #}
79
+
80
+ # deny access to .htaccess files, if Apache's document root
81
+ # concurs with nginx's one
82
+ #
83
+ #location ~ /\.ht {
84
+ # deny all;
85
+ #}
86
+ }