lhm0491 发表于 2008-07-21 14:51

寻求在freebsd7+nginx下泛域名绑定的办法哈

寻求在freebsd7+nginx下泛域名绑定的办法哈 谢谢!:em03:

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

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

lhm0491 发表于 2008-07-21 16:16

:wink: 恩 绑定,那我该怎么做绑定呢 :em03:

scyzxp 发表于 2008-07-21 16:41

原帖由 lhm0491 于 2008-7-21 16:16 发表 http://bbs.chinaunix.net/images/common/back.gif
:wink: 恩 绑定,那我该怎么做绑定呢 :em03:

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_redirectoff;

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

lhm0491 发表于 2008-07-21 16:55

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

      server_name_in_redirectoff;

      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 编辑 ]

lastexile 发表于 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
-------------------------------------

#usernobody;
user www-data;
worker_processes1;

#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;

#pid      logs/nginx.pid;


events {
    worker_connections1024;
}


http {
    include       mime.types;
    default_typeapplication/octet-stream;

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

    #access_loglogs/access.logmain;

    sendfile      on;
    #tcp_nopush   on;

    #keepalive_timeout0;
    keepalive_timeout65;

    #gzipon;

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


       

      set $hostx $host;


      #access_loglogs/host.access.logmain;
      


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

        }
      

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

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

      #error_page404            /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_indexindex.php;
            fastcgi_paramSCRIPT_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 {
            denyall;
      }
    }


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

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


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_namelocalhost;

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

    #    ssl_session_timeout5m;

    #    ssl_protocolsSSLv2 SSLv3 TLSv1;
    #    ssl_ciphersALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

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

}

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

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

scyzxp 发表于 2008-07-29 22:39

原帖由 lastexile 于 2008-7-29 16:56 发表 http://bbs.chinaunix.net/images/common/back.gif
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上面做的.你这这是简单的虚拟主机.

lastexile 发表于 2008-07-29 23:41

我讲错,是泛域名绑定,上边我的conf,确定成功, dns的设置很简单吗,设定 *.xxx.org对应A记录就得了,我想我的理解没错吧。

zhy_aid_cn 发表于 2008-07-31 13:44


        server {
      listen       80;
      server_name*.xxx.com;
      root /www;
      index index.html index.htm index.php;
      access_loglogs/5uelife.cn.access.log;
      location / {
            root   /www;
         indexindex.php;
      }
   
       //你还需要配置rewrite

      location ~ .php$ {
                        fastcgi_pass   127.0.0.1:9000;
                        fastcgi_indexindex.php;
                        fastcgi_paramSCRIPT_FILENAME/www/$fastcgi_script_name;
                        include vhostfcgi.conf;
                        fastcgi_intercept_errors on;
      }
   }

abc3214 发表于 2012-08-25 18:07

我想我的理解没错吧。该怎么做绑定呢

lsstarboy 发表于 2012-08-25 18:52

nginx文档上有,用下划线,或者干脆用xxx.com,或者是*.xxx.com,都会匹配你的那些域名。
页: [1]
查看完整版本: 寻求在freebsd7+nginx下泛域名绑定的办法哈