httpd 配置 webdav 和反向代理服务器

作者: 天兵公园 | 来源:发表于2017-11-07 17:35 被阅读39次

网上搜了很多教程,也配置了很多次,每次也都稀里糊涂配成功了,有在 Ubuntu 和 Centos,也有 Debian 的,至今搞不清 httpd 和 apache2 区别,偶然配置成功了,做下笔记 ...

手头上有个 Debian 8 的服务器,自带了 httpd,但是浏览器输出的 Header 消息显示 Server 是 Apache/2.4.6 (CentOS),一脸懵逼 ...

WebDav 设置

这是 httpd,在 /etc 下有个 httpd 的目录,目录结构如下:

/etc/httpd

apache 好像有 site-enabled 和 site-available 两个文件夹,二脸懵逼。

在 http.conf 文件最后一行,有 IncludeOptional conf.d/*.conf 这一句指令,那么我们只需要把 conf 配置写到 conf.d 这个文件夹下就行了。

启用 webdav 之前,保证下列模块已经加载:mod_dav.so,mod_dav_fs.so,mod_dav_lock.so,mod_auth*.so

配置文件内容如下:

<VirtualHost *:80>
ServerAdmin xx@xx.xx
DocumentRoot "/home/webdav"
ServerName xx.xx.xx
ServerAlias xx.xx.xx
DAVLockDB /var/www/web/DavLock
<Directory "/home/webdav">  
    Dav On
    Options Indexes FollowSymLinks Includes
    Order Allow,Deny  
    Allow from all  
    AllowOverride None  
    #AuthType Digest  
    AuthType Basic  
    AuthName WebDAV-Server  
    #You can use the htdigest program to create the password database:  
    #htdigest -c "/tmp/mips/user.passwd" DAV-upload admin  
    #htpasswd -c "/tmp/mips/user.passwd" admin  
    AuthUserFile "/var/httpd-users"  
    #AuthDigestProvider file  
    AuthBasicProvider file
    require user xuzhi
</Directory>
</VirtualHost>

需要注意的是,目录 /home/webdav 和 文件 /var/www/web/DavLock 最好都设置 777 属性,设置用户和用户组为 apache:apache,可以参考默认文件夹 /var/www/html 的属性。

反向代理设置

代理设置就相对简单了,配置文件如下:

<VirtualHost *:80>
ServerAdmin xx@xx.xx
ServerName xx.xx.xx
ServerAlias xx.xx.xx
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>

普通 Web 静态服务器

也不是太复杂,反正关闭了 ssh 密码登录,索性都用 chmod 777 -R /home/dc 和 chown apache:apache -R /home/dc 设置了一番。

<VirtualHost *:80>
ServerAdmin xx@xx.xx
DocumentRoot "/home/dc"
ServerName xx.xx.me
ServerAlias xx.xx.me
<Directory /home/dc>
    AllowOverride None
    Require all granted
</Directory>
</VirtualHost>

当然线上环境切不可如此,这里纯粹图方便。

相关文章

网友评论

    本文标题:httpd 配置 webdav 和反向代理服务器

    本文链接:https://www.haomeiwen.com/subject/phbjmxtx.html