1.powerdns設置
2.內部網站介紹
web服務器采用nginx,內網dns采用powerdns.
想實現的功能如下
通過ip訪問時跳轉到A頁面,通過域名訪問時,讓其跳轉到B頁面。兩種方式的端口均為80.
頁面A對應的nginx配置
server {
????????listen?????? 80;
??????? server_name? localhost;
??????? #charset koi8-r;
??????? charset utf-8;
??????? access_log? logs/localhost.access.log? main;
??????? error_log? logs/localhost.error.log;
??????? root?? /var/www;
??????? index? index.php index.html index.htm;
??????? autoindex on;
??????? autoindex_exact_size? off;
??????? autoindex_localtime on;
??????? location / {
??????? }
頁面B對應的nginx配置
server {
????????????????listen?????? 80;????
??????????????? server_name? zhidao.AAA.com;
??????????????? #charset koi8-r;
??????????????? charset utf-8;
??????????????? access_log? logs/localhost38.access.log;
??????????????? error_log? logs/localhost38.error.log;
??????????????? location / {
??????????????????????? root?? /var/www/q2a/question2answer-1.7;
??????????????????????? index? index.php index.html index.htm;
??????????????????????? autoindex on;
??????????????????????? autoindex_exact_size? off;
??????????????????????? autoindex_localtime on;
??????????????? }
配置后重啟nginx,
[root@movie conf]# /usr/local/nginx/sbin/nginx -s reload
3.測試
通過IP訪問
通過域名訪問
可以看到,二者分別跳轉到了不同頁面。
總結,以上其實是基于多個域名、同一端口的nginx應用。
本文轉自 xoyabc 51CTO博客,原文鏈接:http://blog.51cto.com/xoyabc/1671414,如需轉載請自行聯系原作者