免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5890 | 回复: 9
打印 上一主题 下一主题

[FreeBSD] 寻求在freebsd7+nginx下泛域名绑定的办法哈 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-21 14:51 |只看该作者 |倒序浏览
寻求在freebsd7+nginx下泛域名绑定的办法哈 谢谢!

我是为了做blog用的
想实现的效果是
用户id1.xxx.com
用户id2.xxx.com
用户id3.xxx.com
用户idn.xxx.com
...
...
...
万网上我已经做了*.xxx.com IP的映射
现在想问在nginx的环境下如何配置才能使得blog多用户二级域名 生效
谢谢哈!

[ 本帖最后由 lhm0491 于 2008-7-21 17:01 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-07-21 16:16 |只看该作者
:wink: 恩 绑定,那我该怎么做绑定呢

论坛徽章:
0
3 [报告]
发表于 2008-07-21 16:41 |只看该作者
原帖由 lhm0491 于 2008-7-21 16:16 发表
:wink: 恩 绑定,那我该怎么做绑定呢


A Default Catchall Virtual Host (in 0.6.x)

http {
    server {
        listen          80 default;
        server_name     _;
        access_log      logs/default.access.log main;

        server_name_in_redirect  off;

        location / {
            index index.html;
            root  /var/www/default/htdocs;
        }
    }
}

论坛徽章:
0
4 [报告]
发表于 2008-07-21 16:55 |只看该作者
http {
    server {
        listen          80 default;
        server_name     _;
        access_log      logs/default.access.log main;

        server_name_in_redirect  off;

        location / {
            index index.html;
            root  /var/www/default/htdocs;
        }
    }
这样写我nginx都启动不来了啊
nginx下泛域名绑定 不需要用*.域名.com的字样么?
我是为了做blog用的
想实现的效果是
用户id1.xxx.com
用户id2.xxx.com
用户id3.xxx.com
用户idn.xxx.com
...
...
...
万网上我已经做了*.xxx.com IP的映射
现在想问在nginx的环境下如何配置才能使得blog多用户二级域名 生效
谢谢哈!

[ 本帖最后由 lhm0491 于 2008-7-21 16:59 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2008-07-29 16:56 |只看该作者
Me这几天在虚拟机做的泛域名解释的nginx配置

http://www.lpfrx.com =>  /var/www/lpfrx.com/www
http://xxx.lpfrx.com =>  /var/www/lpfrx.com/xxx
http://192.168.0.100 => /var/www/0.100/192.168


nginx.conf
-------------------------------------

#user  nobody;
user www-data;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] $request '
    #                  '"$status" $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
      
        listen       80;
        #server_name  localhost;
        server_name _;
        #charset koi8-r;
        


       

        set $hostx $host;


        #access_log  logs/host.access.log  main;
        


        if ( $host ~* (.*)\.(.*)\.(.*) ) {
       
          set $hostx $2.$3/$1;

        }
        

        location / {
            #root   html;
            root /var/www/$hostx;
            index  index.php index.html index.htm;

            if (-d $request_filename)
                    {
         
                rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
                
             }
           
            rewrite ^/index(.*)/$ /index.php?id=$1 last;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
           # root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/$hostx/$fastcgi_script_name;
            include        /usr/local/nginx/conf/fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
       

        location ~ /\.ht {
            deny  all;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

我也记录在我的blog里去: http://www.lpfrx.com/archives/105/

[ 本帖最后由 lastexile 于 2008-10-16 18:59 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2008-07-29 22:39 |只看该作者
原帖由 lastexile 于 2008-7-29 16:56 发表
Me这几天在虚拟机做的泛域名解释的nginx配置

http://www.test.com =>  /var/www/test.com/www
http://xxx.test.com =>  /var/www/test.com/xxx
http://192.168.0.100 => /var/www/0.100/192.168


ngin ...



做成了吗?你概念上就弄错了,泛域名支持是在DNS上面做的.你这这是简单的虚拟主机.

论坛徽章:
0
7 [报告]
发表于 2008-07-29 23:41 |只看该作者
我讲错,是泛域名绑定,上边我的conf,确定成功, dns的设置很简单吗,设定 *.xxx.org对应A记录就得了,我想我的理解没错吧。

论坛徽章:
0
8 [报告]
发表于 2008-07-31 13:44 |只看该作者

  1.         server {
  2.         listen       80;
  3.         server_name  *.xxx.com;
  4.         root /www;
  5.         index index.html index.htm index.php;
  6.         access_log  logs/5uelife.cn.access.log;
  7.         location / {
  8.             root   /www;
  9.            index  index.php;
  10.         }
  11.    
  12.        //你还需要配置rewrite

  13.         location ~ .php$ {
  14.                         fastcgi_pass   127.0.0.1:9000;  
  15.                         fastcgi_index  index.php;
  16.                         fastcgi_param  SCRIPT_FILENAME  /www/$fastcgi_script_name;
  17.                         include vhostfcgi.conf;
  18.                         fastcgi_intercept_errors on;
  19.         }
  20.      }

复制代码

论坛徽章:
0
9 [报告]
发表于 2012-08-25 18:07 |只看该作者
我想我的理解没错吧。该怎么做绑定呢

论坛徽章:
54
2017金鸡报晓
日期:2017-02-08 10:39:42操作系统版块每日发帖之星
日期:2016-03-08 06:20:00操作系统版块每日发帖之星
日期:2016-03-07 06:20:00操作系统版块每日发帖之星
日期:2016-02-22 06:20:00操作系统版块每日发帖之星
日期:2016-01-29 06:20:00操作系统版块每日发帖之星
日期:2016-01-27 06:20:00操作系统版块每日发帖之星
日期:2016-01-20 06:20:00操作系统版块每日发帖之星
日期:2016-01-06 06:20:0015-16赛季CBA联赛之江苏
日期:2015-12-21 20:00:24操作系统版块每日发帖之星
日期:2015-12-21 06:20:00IT运维版块每日发帖之星
日期:2015-11-17 06:20:002015亚冠之广州恒大
日期:2015-11-12 10:58:02
10 [报告]
发表于 2012-08-25 18:52 |只看该作者
nginx文档上有,用下划线,或者干脆用xxx.com,或者是*.xxx.com,都会匹配你的那些域名。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP