pve下使用lxc 直通硬盘搭建 nas 服务 全面替代群晖 freenas OMV 等 服务套ssl

本文 是 pve lxc 搭建nas 的系列文章 的一部分。 因为篇幅较长,所以分开。

原文索引 :https://dev.leiyanhui.com/pve/lxc-nas

本文主要内容 webdav https-git minio s3对象储存 思源 套ssl的相关记录。

我这里使用 nginxwebui的修改版本,具体看看之前文章点这里。这里只记录最终配置文件。

# nginx反代思源

需要ws,最终配置如下

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
server {
  server_name 域名;
  listen 50443 ssl http2;
  ssl_certificate /home/nginxWebUI/.acme.sh/域名/fullchain.cer;
  ssl_certificate_key /home/nginxWebUI/.acme.sh/域名/jia.leiyanhui.com.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  listen 50080;
  if ($scheme = http) {
    return 301 https://$host:50443$request_uri;
  }
  error_page 497 https://$host:50443; #解决http到ssl端口的400错误;
  location / {
    proxy_pass http://10.1.1.68/;
    proxy_redirect http:// https://;
  }
  location /ws {
    proxy_pass http://10.1.1.68;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_redirect http:// https://;
    proxy_read_timeout 60s;
  }
}

# nginx反代网盘类

需要安装模块 more_set_headers alpine下包名称nginx-mod-http-headers-more 在nginx.conf配置文件的http块(注意 不是 server块)中添加map指令,将请求头Destination中的https替换为http,并解决webdav重命名中文文件夹的乱码问题:

1
2
3
4
map $http_destination $webdav_dest {
    ~*https://(.+) http://$1;
    default $http_destination;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
location / {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Range $http_range;
	proxy_set_header If-Range $http_if_range;
  proxy_redirect off;
  proxy_pass http://127.0.0.1:5244;
  # the max size of file to upload
  client_max_body_size 20000m;
}
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计