nginx uwsgi 配置泛二级域名解析失败
需求(以sina.com为例):
http://abc.sina.com 到 http://www.sina.com/blog/abc
http://abc.sina.com/pics 到 http://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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论