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应用。
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应用。
相关文章推荐
- 开放Nginx在文件夹列表功能
- nginx配置多个虚拟ip访问
- Nginx服务器nginx.conf的配置文件说明
- nginx+lua安装配置
- nginx总结
- CentOS 6.5用RPM安装Nginx
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- 如何改变nginx显示静态目录文件的文件名长度
- 使用 NgxFancyIndex 代替nginx原有的autoindex模块美化文件显示
- Nginx打开目录浏览功能(autoindex)
- 记vagrant nginx sendfile问题
- nginx 跨域acl
- 从nginx日志中统计nginx缓存命中率
- nginx+lua_nginx+GraphicsMagick缩略图+tfs获取原图+ngx_cache_purge
- Nginx学习之keepalive
- Nginx列出目录和文件并用密码控制访问权限配置方法
- nginx服务器下编写cgi程序
- nginx-lua-fastdfs-GraphicsMagick整合
- Nginx 1.9.2新特性
- Nginx入门