apache 防盜鏈 與 地址重寫

一、apache 防盜鏈    地址重寫

http://192.168.4.254/254.html

盜鏈代碼

192.168.4.254  web-server

vim  254.html

<html>

     <body>

         <a href="http://192.168.4.253/one.png" >  show p_w_picpath </a>

     </body>

</html>

 

192.168.4.253服務器上做防盜鏈配置

vim  httpd.conf

<Directory"/usr/local/httpd/htdocs">

   Options Indexes FollowSymLinks

   AllowOverride None

   Order allow,deny

   Allow from all

RewriteEngine on

RewriteCond %{HTTP_REFERER}  !^$

RewriteCond %{HTTP_REFERER}  !^http://192.168.4.253/.*$  [NC]

RewriteRule .*\.(jpg|gif|png|jpeg)$ http://192.168.4.253/err.html [R,L]

</Directory>

 

[root@localhost htdocs]# cat err.html

<html>

     <body>

          <h1>dao lian  ke  chi</h1>

     </body>

</html>

 

 

地址重寫:修改客戶端訪問自己的url地址

 

常用指令

RewriteEngine:啓用(設爲On)重寫引擎

RewriteCond:指定重寫條件

RewriteRule:設置重寫策略

 

 

a.jpeg

xxx.jpeg

 

 192.168.4.254

http://server-ip/254.html

                           盜鏈代碼

 

 

 

啓動ip192.168.4.253上服務器上的源碼apache 服務

能夠在客戶端地址254pc上訪問其下的網頁文件。

 

 

搭建rsync服務器

本地同步

本地同步時不需要啓動rsync服務

安裝rsync軟件包

一、rsync  (做數據遠程同步的服務)

     同步數據時只同步數據源新產生的文件和有變化的文件

     數據傳輸時是加密的

 

本地數據同步(要有rsync命令 /boot    /bootbak

rpm -q  rsync

命令格式

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=:指定認證口令文件

 

 

spacer.gif

 

[root@mail testdir]# rsync  -av --backup --backup-dir=/backdir  --delete /testdir/     /testbak/

網絡數據同步(rsync服務)

遠程同步:

ip192.168.4.254的網站服務器的網頁文件,IP192.168.4.253的網站服務器上下載

 

1

在服務器253254上運行網站服務器。

vim /etc/xinetd.d/rsync

2、在253上配置rsync服務共享目錄

     /usr/local/httpd/htdocs/

2.1

[root@localhost htdocs]# 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/xinetd  restart

[root@localhost ~]# netstat  -untlap | grep :873

 

 

獨立運行 (常駐內存)

[root@localhost ~]# vim  /etc/xinetd.d/rsync

       disable = yes

[root@localhost xinetd.d]#

/etc/init.d/xinetd  restart

touch /etc/rsyncd.conf  創建主配置文件

/usr/bin/rsync --daemon   啓動服務

netstat -utnalp | grep :873

pkill -9 rsync    停止服務

 

rsync服務設置爲獨立啓動模式:

[root@mail xinetd.d]# vim/etc/xinetd.d/rsync

[root@mail xinetd.d]# grep yes/etc/xinetd.d/rsync

       disable = yes

 

[root@mail xinetd.d]# /etc/init.d/xinetdrestart

 

[root@mail xinetd.d]# netstat -utnalp |grep :873

 

[root@mail xinetd.d]# touch  /etc/rsyncd.conf

[root@mail xinetd.d]# /usr/bin/rsync  --daemon

[root@mail xinetd.d]# 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 -a  user@host::共享名  本地目錄

 

 

 

[root@svr6 ~]# rsync    [email protected]::

 

客戶端下載rsync服務器共享的數據到備份目錄下

 

mkdir /bakdir

[root@svr6 ~]# touch /etc/user.txt

 

[root@svr6 ~]# vim  /etc/user.txt

get88

:wq

 

[root@svr6 ~]# chmod 600   /etc/user.txt

 

[root@svr6 ~]# rsync  -av --backup --backup-dir=/oldback --delete --password-file=/etc/user.txt [email protected]::sharedir  /bakdir

 

 

上傳數據(rsync服務器端的開放用戶的上傳權限,目錄本身要有被寫的權限)

格式:

rsync  -a   本地目錄     user@host::共享名

獨立服務

 

[root@localhost xinetd.d]# vim/etc/xinetd.d/rsync

disabled = yes

[root@localhost xinetd.d]#/etc/init.d/xinetd restrart

[root@localhost xinetd.d]# touch/etc/rsyncd.conf

[root@localhost xinetd.d]# which rsync

/usr/bin/rsync

[root@localhost xinetd.d]# /usr/bin/rsync--daemon

 

編輯主配置文件共享目錄給客戶端

[root@localhost xinetd.d]# 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    [email protected]::webdit          /var/www/html

 

 

 

man   rsyncd.conf     查看配置文件的幫助信息

編輯主配置文件共享目錄給客戶端

vim /etc/rsyncd.conf

[webdir]

path = /usr/local/httpd/htdocs/

read only =  no

auth  users = 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 -q  rsync

 

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

 

 

下載數據的命令格式

rsync 選項  username@rsync_ip::共享名  本地目錄

 

創建保存用戶密碼的文件

echo  123456  >    /etc/userp.txt

chmod 600  /etc/userp.txt

 

從服務器上下載文件

[root@localhost html]# rsync -a --delete--password-file=/etc/userp.txt [email protected]::webdir  /var/www/html/

 

rsync服務練習

rsync服務器本機網站目錄共享,客戶端可以使用webuser用戶訪問時有上傳和下載的權限  密碼是webuser88

 

rsync服務器本機/homewok目錄共享 客戶端可以使用webuser用戶訪問,只有下載數據權限。下載數據時,備份刪除的文件到本機的/bakdir目錄裏。

 

把用戶用戶上傳、下載數據的操作使用計劃任務完成,執行任務週期自己設置。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

二、ntp  

 

服務器   192.168.1.100

 

 

客戶端    192.168.1.200

 

ntpq -p  192.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的分佈情況.簡單地說這個數值的絕對值越小,主機的時間就越精確

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章