nginx uwsgi 配置泛二级域名解析失败

需求(以sina.com为例):
http://abc.sina.comhttp://www.sina.com/blog/abc
http://abc.sina.com/picshttp://www.sina.com/blog/abc/pics
网址要隐式的,地址栏显示 http://abc.sina.com/pics

server{
    listen   80; ## listen for ipv4; this line is default and implied

    server_name sina.com www.sina.com *.sina.com;

set $subdomain '';
if ( $host ~* (\b(?!www\b)\w+)\.sina\.com ) {
set $subdomain $1;
set $suburl $request_uri;
}




    location / {
          proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://sina.com;
           if ( $suburl ~ "/$" ) {
              rewrite ^/(.*) /blog/$subdomain break;
           }
           root /var/www/sina.com/;
           uwsgi_pass 127.0.0.1:8082;
           include uwsgi_params;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
    {
      root /var/www/sina.com/;
      access_log off;
      expires 30d;
      break;
    }
}

                             
回复
阅读 3.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏