星期三, 12月 03, 2014

mod_rewrite@Apache

我常在想,網誌名稱是不是要來改一下好了(偷笑!)

最近遇到一個比較棘手的問題,想了很久,於是突發奇想,是否有可能透過url_rewrite來解決呢?於是花了些時間去找資料跟實做,那麼把一些結果紀錄一下吧!

什麼是url_rewrite,顧名思義就是網址重寫(這樣翻對嗎?)

廢話不多範例是最好的說明,來看一下最常用的應用!

範例一:如果我想做HTTP自動轉HTTPS
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

 
另外紀錄一些我覺得比較特別的應用,符合某特定來源

RewriteEngine on 
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.168$ [OR]
RewriteCond %{REMOTE_ADDR} ^172\.16\.$ [OR]
RewriteCond %{REMOTE_ADDR} ^10\.$ [OR] 
RewriteRule .......

HTTP跟HTTPS下都能運作

<VirtualHost *:80> 
RewriteEngine on
RewriteCond ....
RewriteRule .....
</VirtualHost > <VirtualHost *:443>
RewriteEngine on
RewriteCond ....
RewriteRule ....
</VirtualHost >

 其實我主要是要紀錄一下如何在HTTP跟HTTPS下運作,其他技術文件網路上超級多的了!
 
參考來源:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html 
http://www.widexl.com/tutorials/mod_rewrite.html 
http://www.whoopis.com/howtos/apache-rewrite.html
http://stackoverflow.com/questions/22221203/apache2-rewrite-rule-not-working-remote-address

   
 
 

星期二, 11月 11, 2014

OpenVAS @CentOS 6

時格許久再次安裝OpenVAS,依稀記得整個步驟簡單到不行。

為了再次確認是否在新版本有所差異,還是回官方確認一下。

Step 1: Configure Atomicorp Repository
(as user root, only once)
wget -q -O - http://www.atomicorp.com/installers/atomic |sh
Step 2: Quick-Install OpenVAS
(as user root, only once)
yum upgrade
yum install openvas
openvas-setup
Step 3: Quick-Start OpenVAS

( nothing to do, all is up and running directly after installation )
Step 4: Log into OpenVAS with user created in the step 2
Open https://localhost:9392/.


看到這段之後,放心的超簡單的安裝!

但是跑
# openvas-setup

卻停在
Error: rsync failed. Your NVT collection might be broken now.
 
後來爬了一下討論,才發現原來他需要使用873 port 更新!
 
一切又回到當初的單純美好簡單! 
 
對了,當初裝好時有碰到掃描直接完成。 
根據log 紀錄來看是出現掃描主機失敗,後來把selinux關閉後就正常了。XD

參考來源:
[Openvas-discuss] can not set up openvas + Centos 6.5