快捷搜索:   服务器  PHP  安全  IIS  linux 安全

在Nginx下支持泛域名解析

在Nginx下支持泛域名解析其实很简单.只要在在编译 Nginx的时候加上以下代码即可

--with-http_sub_module

在配置nginx时:

server {
        # Replace this port with the right one for your requirements
        listen      80;#could also be 1.2.3.4:80
 
        # Multiple hostnames seperated by spaces.  Replace these as well.
        server_name  www.yourdomain.com *.yourdomain.com;
        #Alternately: _ *
        root /PATH/TO/WEBROOT/$host;
        error_page  404              http://yourdomain.com/errors/404.html;
        access_log  logs/yourdomain.com.access.log;
        location / {
            root  /PATH/TO/WEBROOT/$host/;
            index  index.php;
        }
 
        # serve static files directly
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {
            access_log        off;
            expires          30d;
        }
 
        location ~ .php$ {   
          # By all means use a different server for the fcgi processes if you need to   
          fastcgi_pass  127.0.0.1:YOURFCGIPORTHERE;
          fastcgi_index  index.php;
 
          fastcgi_param  SCRIPT_FILENAME  /PATH/TO/WEBROOT/$host/$fastcgi_script_name;
          fastcgi_param  QUERY_STRING    $query_string;
          fastcgi_param  REQUEST_METHOD  $request_method;
          fastcgi_param  CONTENT_TYPE    $content_type;
          fastcgi_param  CONTENT_LENGTH  $content_length;
          fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
          fastcgi_param  REQUEST_URI        $request_uri;
          fastcgi_param  DOCUMENT_URI      $document_uri;
          fastcgi_param  DOCUMENT_ROOT      $document_root;
          fastcgi_param  SERVER_PROTOCOL    $server_protocol;
          fastcgi_param  REMOTE_ADDR        $remote_addr;
          fastcgi_param  REMOTE_PORT        $remote_port;
          fastcgi_param  SERVER_ADDR        $server_addr;
          fastcgi_param  SERVER_PORT        $server_port;
          fastcgi_param  SERVER_NAME        $server_name;
          fastcgi_intercept_errors on;
        }
顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论