formatuu 发表于 2018-11-22 09:49:08

apache 防盗链 与 地址重写

一、apache 防盗链与地址重写
http://192.168.4.254/254.html
盗链代码
192.168.4.254web-server
vim254.html

   
         show image
   


在192.168.4.253服务器上做防盗链配置
vimhttpd.conf

   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://192.168.4.253/.*$
RewriteRule .*\.(jpg|gif|png|jpeg)$ http://192.168.4.253/err.html


# cat err.html

   
          dao liankechi
   



地址重写:修改客户端访问自己的url地址

常用指令
RewriteEngine:启用(设为On)重写引擎
RewriteCond:指定重写条件
RewriteRule:设置重写策略


a.jpeg
xxx.jpeg

192.168.4.254
http://server-ip/254.html
                           盗链代码



启动ip192.168.4.253上服务器上的源码apache 服务
能够在客户端地址254的pc上访问其下的网页文件。


搭建rsync服务器
本地同步
本地同步时不需要启动rsync服务
安装rsync软件包
一、rsync(做数据远程同步的服务)
   同步数据时只同步数据源新产生的文件和有变化的文件
   数据传输时是加密的

本地数据同步(要有rsync命令) (/boot    /bootbak)
rpm -qrsync
命令格式
rsync【选项】    源文件    目标目录
rsync   –av            /usr/http         /http      备份包含http这个文件夹在内的所有文件
rsync    –av            /usr/http/         /http             备份http下所有文件

mkdir/webback
rsync -av /usr/local/httpd/htdocs   /webback/

rsync -av /usr/local/httpd/htdocs/ /webback/
选项
--delete:删除目标有而源没有的文件
--backup 删除目标有而源没有的文件时先备份删除的文件
--backup-dir=DIR指定备份删除的文件的目录
--password-file=:指定认证口令文件


http://blog.51cto.com/e/u261/themes/default/images/spacer.gif

# rsync-av --backup --backup-dir=/backdir--delete /testdir/   /testbak/
网络数据同步(rsync服务)
远程同步:
ip是192.168.4.254的网站服务器的网页文件,从IP是192.168.4.253的网站服务器上下载

1、
在服务器253和254上运行网站服务器。
vim /etc/xinetd.d/rsync
2、在253上配置rsync服务共享目录
   /usr/local/httpd/htdocs/
2.1
# rpm -q rsync
rsync-3.0.6-4.el5_7.1

2.2 启动rsync服务

非独立运行(不常驻内存)
*所有非独立运行的服务,统一有系统的xinetd服务管理。
vim /etc/xinetd.d/rsync
disable = no
#disable = yes
:wq

/etc/init.d/xinetdrestart
# netstat-untlap | grep :873


独立运行 (常驻内存)
# vim/etc/xinetd.d/rsync
       disable = yes
#
/etc/init.d/xinetdrestart
touch /etc/rsyncd.conf创建主配置文件
/usr/bin/rsync --daemon   启动服务
netstat -utnalp | grep :873
pkill -9 rsync    停止服务

将rsync服务设置为独立启动模式:
# vim/etc/xinetd.d/rsync
# grep yes/etc/xinetd.d/rsync
       disable = yes

# /etc/init.d/xinetdrestart

# netstat -utnalp |grep :873

# touch/etc/rsyncd.conf
# /usr/bin/rsync--daemon
# netstat -utnalp |grep :873


编辑配置文件共享数据(与samba服务的共享方式一样)
vim/etc/rsyncd.conf
[共享名]
path = 共享目录的物理路径
comment = 描述信息
read only = yes/no
auth users = 用户名
secrets file = 目录名/文件名(用户名:密码600)


192.168.1.100服务器 /testdir 目录共享给客户端
访问时使用用户名 getuser密码 get88只有下载数据的权限
共享名sharedir


客户端下载数据的命令格式(客户端要提供rsync命令)

下载数据:
rsync -auser@host::共享名本地目录



# rsync    getuser@192.168.1.100::

客户端下载rsync服务器共享的数据到备份目录下

mkdir /bakdir
# touch /etc/user.txt

# vim/etc/user.txt
get88
:wq

# chmod 600   /etc/user.txt

# rsync-av --backup --backup-dir=/oldback --delete --password-file=/etc/user.txt getuser@192.168.1.100::sharedir/bakdir


上传数据(rsync服务器端的开放用户的上传权限,目录本身要有被写的权限)
格式:
rsync-a   本地目录   user@host::共享名
独立服务

# vim/etc/xinetd.d/rsync
disabled = yes
#/etc/init.d/xinetd restrart
# touch/etc/rsyncd.conf
# which rsync
/usr/bin/rsync
# /usr/bin/rsync--daemon

编辑主配置文件共享目录给客户端
# vim/etc/rsyncd.conf

[共享名]
path         =   /usr/local/httpd/htdocs/--共享目录
read only         =       no   /yes
auth users =webuser                                    访问用户名
secrets   file    =       /etc/user_pass.txt         访问密码

vim /etc/user_pass.txt
webuser : 123456
:x
chmod 600 /etc/user_pass.txt

pkill          -9      rsync


[*]  共享目录用户有上传的权限,低于文件系统本身的权限.

客户端访问:
rsync       -q


rsync         -av    --delete    webuser@192.168.4.253::webdit          /var/www/html



man   rsyncd.conf   查看配置文件的帮助信息
编辑主配置文件共享目录给客户端
vim /etc/rsyncd.conf

path = /usr/local/httpd/htdocs/
read only =no
authusers = webuser
secrets file = /etc/user_pass.txt
:wq
vim /etc/user_pass.txt
webuser:123456
:wq
chmod 600/etc/user_pass.txt
pkill-9   rsync
/usr/bin/rsync   --daemon

*配置文件中的权限,低于文件系统本身的权限。

客户端访问:
安装提供访问rsync服务器的rsync命令
rpm -qrsync

rsync   rsync_ip::    查看服务器端的共享名


下载数据的命令格式
rsync 选项username@rsync_ip::共享名本地目录

创建保存用户密码的文件
echo123456>    /etc/userp.txt
chmod 600/etc/userp.txt

从服务器上下载文件
# rsync -a --delete--password-file=/etc/userp.txt webuser@192.168.4.253::webdir/var/www/html/

rsync服务练习
把rsync服务器本机网站目录共享,客户端可以使用webuser用户访问时有上传和下载的权限密码是webuser88

把rsync服务器本机/homewok目录共享, 客户端可以使用webuser用户访问,只有下载数据权限。下载数据时,备份删除的文件到本机的/bakdir目录里。

把用户用户上传、下载数据的操作使用计划任务完成,执行任务周期自己设置。















二、ntp

服务器   192.168.1.100


客户端    192.168.1.200

ntpq -p192.168.1.100

remote :响应这个请求的NTP服务器的名称
refid :NTP服务器使用的上一级ntp服务器
st :remote远程服务器的级别.从高到低可以设定为1-16.为了减缓负荷和网络堵塞,原则上应该避免直接连接到级别为1的服务器的.
when:上一次成功请求之后到现在的秒数。
poll :本地机和远程服务器多少时间进行一次同步(单位为秒).在一开始运行NTP的时候这个poll值会比较小,那样和服务器同步的频率也就增加了,可以尽快调整到正确的时间范围,之后poll值会逐渐增大,同步的频率也就会相应减小
reach :这是一个八进制值,用来测试能否和服务器连接.每成功连接一次它的值就会增加
delay :从本地机发送同步要求到ntp服务器的roundtrip time
offset :主机通过NTP时钟同步与所同步时间源的时间偏移量,单位为毫秒(ms)。offset越接近于0,主机和ntp服务器的时间越接近
jitter :这是一个用来做统计的值.它统计了在特定个连续的连接数里offset的分布情况.简单地说这个数值的绝对值越小,主机的时间就越精确

  




页: [1]
查看完整版本: apache 防盗链 与 地址重写