WINDOWS系統(tǒng)云虛擬主機(jī)及馳云產(chǎn)品訪問(wèn)IP限制方法
使用新網(wǎng)Windows系統(tǒng)云虛擬主機(jī)和馳云主機(jī)的客戶,如需要限制某些IP訪問(wèn),或只允許某些IP訪問(wèn),可以通過(guò)如下方式實(shí)現(xiàn)。
1. 限制部分IP訪問(wèn):
請(qǐng)自行創(chuàng)建并編寫(xiě)web.config文件,上傳至網(wǎng)站根目錄下的/WWW/目錄中。
內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="RequestBlockingRule1" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <conditions logicalGrouping="MatchAny"> <add input="{REMOTE_ADDR}" pattern="192.168.0.1" /> <add input="{REMOTE_ADDR}" pattern="192.168.1.*" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." /> </rule> </rules> </rewrite> </system.webServer> </configuration> |
RequestBlockingRule1 限制了192.168.0.1單個(gè)IP訪問(wèn)及192.168.1.* 整個(gè)C段訪問(wèn)。
2. 只允許部分IP訪問(wèn)
請(qǐng)自行創(chuàng)建并編寫(xiě)web.config文件,上傳至網(wǎng)站根目錄下的/WWW/目錄中。
內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="RequestBlockingRule1" patternSyntax="Wildcard" stopProcessing="true"> <match url="*" /> <conditions> <add input="{REMOTE_ADDR}" pattern="192.168.0.1" negate="true" /> <add input="{REMOTE_ADDR}" pattern="192.168.1.*" negate="true" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." /> </rule> </rules> </rewrite> </system.webServer> </configuration> |
RequestBlockingRule1 只允許192.168.0.1單個(gè)IP訪問(wèn)及192.168.1.* 整個(gè)C段訪問(wèn)。
說(shuō)明:
通過(guò)URL重寫(xiě)功能,可以實(shí)現(xiàn)基于URL路徑、用戶代理標(biāo)頭、IP地址、查詢字符串、引用站點(diǎn)、主機(jī)頭的限制,滿足對(duì)網(wǎng)站的保護(hù),新網(wǎng)新虛擬主機(jī)及馳云主機(jī)支持網(wǎng)站自定制的URL重寫(xiě)功能。
如需要更復(fù)雜限制策略,請(qǐng)?jiān)诒镜豂IS7以上版本安裝URL重寫(xiě)模塊進(jìn)行調(diào)試后上傳。