Spaces:
Running
Running
| worker_processes 1; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| include /etc/nginx/mime.types; | |
| default_type application/octet-stream; | |
| sendfile on; | |
| keepalive_timeout 65; | |
| client_max_body_size 0; | |
| server { | |
| listen 7860; | |
| server_name _; | |
| # ----------------------------- | |
| # code-server (主入口,需要密码) | |
| # ----------------------------- | |
| location / { | |
| proxy_pass http://127.0.0.1:8443; | |
| proxy_http_version 1.1; | |
| # WebSocket support (code-server 编辑器需要) | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection "upgrade"; | |
| 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; | |
| # 长连接超时 | |
| proxy_read_timeout 86400s; | |
| proxy_send_timeout 86400s; | |
| } | |
| # ----------------------------- | |
| # dufs 文件服务 (公开,无需登录) | |
| # ----------------------------- | |
| location /files/ { | |
| proxy_pass http://127.0.0.1:5000; | |
| proxy_http_version 1.1; | |
| 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; | |
| # CORS 支持 | |
| add_header Access-Control-Allow-Origin *; | |
| add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS, PROPFIND, MKCOL, COPY, MOVE'; | |
| add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,Depth'; | |
| add_header Access-Control-Max-Age 86400; | |
| # dufs WebDAV 需要 | |
| proxy_set_header X-Forwarded-Prefix /files; | |
| # OPTIONS 预检请求直接返回 | |
| if ($request_method = OPTIONS) { | |
| add_header Access-Control-Allow-Origin *; | |
| add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS, PROPFIND, MKCOL, COPY, MOVE'; | |
| add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,Depth'; | |
| add_header Access-Control-Max-Age 86400; | |
| add_header Content-Length 0; | |
| add_header Content-Type text/plain; | |
| return 204; | |
| } | |
| } | |
| # ----------------------------- | |
| # 旧的 absproxy 路径,重定向到新路径 | |
| # ----------------------------- | |
| location /absproxy/5000/ { | |
| return 301 /files/; | |
| } | |
| } | |
| } |