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,如需转载请自行联系原作者