dragg2 commited on
Commit
5bfbaae
·
verified ·
1 Parent(s): e8539ed

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -15
Dockerfile CHANGED
@@ -52,14 +52,9 @@ RUN rm -rf /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* && \
52
  listen 7860 default_server;\n\
53
  server_name _;\n\
54
  \n\
55
- # 默认需要认证\n\
56
- auth_basic "Restricted Access";\n\
57
- auth_basic_user_file /etc/nginx/.htpasswd;\n\
58
- \n\
59
- # 文件上传限制\n\
60
  client_max_body_size 500M;\n\
61
  \n\
62
- # 静态文件目录)\n\
63
  location ~ ^/(demo|file|static)/ {\n\
64
  auth_basic off;\n\
65
  proxy_pass http://127.0.0.1:8012;\n\
@@ -71,8 +66,38 @@ RUN rm -rf /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* && \
71
  proxy_read_timeout 300s;\n\
72
  }\n\
73
  \n\
74
- # 反向代理到 KKFileView\n\
 
 
 
 
 
 
 
75
  location / {\n\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  proxy_pass http://127.0.0.1:8012;\n\
77
  proxy_set_header Host $http_host;\n\
78
  proxy_set_header X-Real-IP $remote_addr;\n\
@@ -81,15 +106,8 @@ RUN rm -rf /etc/nginx/sites-enabled/* /etc/nginx/conf.d/* && \
81
  proxy_buffering off;\n\
82
  proxy_read_timeout 300s;\n\
83
  }\n\
84
- \n\
85
- # 健康检查端点\n\
86
- location /health {\n\
87
- auth_basic off;\n\
88
- return 200 "OK";\n\
89
- add_header Content-Type text/plain;\n\
90
- }\n\
91
  }\n' > /etc/nginx/conf.d/kkfileview.conf
92
-
93
  # 6. 启动脚本
94
  RUN printf '#!/bin/bash\n\
95
  set -e\n\
 
52
  listen 7860 default_server;\n\
53
  server_name _;\n\
54
  \n\
 
 
 
 
 
55
  client_max_body_size 500M;\n\
56
  \n\
57
+ # 静态文件目录\n\
58
  location ~ ^/(demo|file|static)/ {\n\
59
  auth_basic off;\n\
60
  proxy_pass http://127.0.0.1:8012;\n\
 
66
  proxy_read_timeout 300s;\n\
67
  }\n\
68
  \n\
69
+ # 健康检查端点\n\
70
+ location /health {\n\
71
+ auth_basic off;\n\
72
+ return 200 "OK";\n\
73
+ add_header Content-Type text/plain;\n\
74
+ }\n\
75
+ \n\
76
+ # 主要预览路径 - 基于 Referer 白名单\n\
77
  location / {\n\
78
+ set $auth_required "Restricted Access";\n\
79
+ \n\
80
+ # 替换为域名\n\
81
+ if ($http_referer ~* "^https?://.*\\.cloudpaste\\.qzz\\.io") {\n\
82
+ set $auth_required off;\n\
83
+ }\n\
84
+ \n\
85
+ # 部署在 HuggingFace Spaces\n\
86
+ if ($http_referer ~* "^https?://.*\\.hf\\.space") {\n\
87
+ set $auth_required off;\n\
88
+ }\n\
89
+ \n\
90
+ # 开发环境支持\n\
91
+ if ($http_referer ~* "^https?://localhost") {\n\
92
+ set $auth_required off;\n\
93
+ }\n\
94
+ if ($http_referer ~* "^https?://127\\.0\\.0\\.1") {\n\
95
+ set $auth_required off;\n\
96
+ }\n\
97
+ \n\
98
+ auth_basic $auth_required;\n\
99
+ auth_basic_user_file /etc/nginx/.htpasswd;\n\
100
+ \n\
101
  proxy_pass http://127.0.0.1:8012;\n\
102
  proxy_set_header Host $http_host;\n\
103
  proxy_set_header X-Real-IP $remote_addr;\n\
 
106
  proxy_buffering off;\n\
107
  proxy_read_timeout 300s;\n\
108
  }\n\
 
 
 
 
 
 
 
109
  }\n' > /etc/nginx/conf.d/kkfileview.conf
110
+
111
  # 6. 启动脚本
112
  RUN printf '#!/bin/bash\n\
113
  set -e\n\