您的位置:首页 > 运维架构 > Nginx

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

2015-07-06 17:58 996 查看
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应用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: