nginx 反向代理到 apache webdav

nginx 反向代理到 apache webdav

因此我开始使用 nginx 反向代理一些服务。其中一个是 Apache 下的 webdav 服务器。这是我的配置文件:

server {

    listen 80;
    listen [::]:80;

    server_name webdav.server.com www.webdav.server.com;

    location / {
            proxy_pass http://192.168.1.200/backup;
            proxy_set_header Host $host;
    }

    location /backup {
            proxy_pass http://192.168.1.200/backup;
            proxy_set_header Host $host;
    }
}

如果我删除该location /backup { ... }指令,它将停止工作。
有没有更简洁的方法来解决这个问题?

答案1

嗯,实际上这个问题已经通过编辑 Apache Webdav 配置文件解决了。

从:

<VirtualHost *:80>
    <Directory "/var/www/html">
        AllowOverride All
    </Directory>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /backup /mnt/Backup/Windows
    <Directory /mnt/Backup/Windows>
       DAV On
       AuthType Basic
       AuthName "Windows"
       AuthUserFile /xxxx/passwd.dav
       Require valid-user
    </Directory>

</VirtualHost>

到:

<VirtualHost *:80>
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined

   ServerName webdav.eddienetworks.ddnsfree.com
   ServerAlias *.webdav.eddienetworks.ddnsfree.com
   DocumentRoot /mnt/Backup/Windows

   <Directory /mnt/Backup/Windows>
      DAV On
      AuthType Basic
      AuthName "Windows"
      AuthUserFile /xxxx/passwd.dav
      Require valid-user
</Directory>

</VirtualHost>   

生成的 nginx 代理文件变成:

server {

   listen 80;
   listen [::]:80;
   server_name webdav.server.com www.webdav.server.com;

   location / {
      proxy_pass http://192.168.1.200/backup;
      proxy_set_header Host $host;
   }
}

希望对以后能有些帮助。

相关内容