码迷,mamicode.com
首页 > Web开发 > 详细

powerdns与nginx结合实现以域名和IP方式访问web服务器80端口时分别跳转到不同页面

时间:2015-07-06 19:57:57      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:powerdns nginx

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访问


技术分享

通过域名访问

技术分享



可以看到,二者分别跳转到了不同页面。

powerdns与nginx结合实现以域名和IP方式访问web服务器80端口时分别跳转到不同页面

标签:powerdns nginx

原文地址:http://xoyabc.blog.51cto.com/7401264/1671414

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!