关于多站点的配置其实很简单
1.多站点:
提示:其实就是一个站点一个server,具体配置自己设置,例如:
server {
listen 80;
server_name nocmt.com;
location /static/ {
root /home/suly;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/suly/suly.sock;
}
}
server {
listen 80;
server_name a.nocmt.com;
location /static/ {
root /home/a;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/a/a.sock;
}
}
2.多域名重定向到主站:
由于自己www.nocmt.com和nocmt.com都指向同一个网站首页,如果每个server都设置一样的不但浪费资源还影响排名,所以我们需要301重定向,设置十分简单,官方推荐做法(以我的网站为例):
server {
listen 80;
server_name nocmt.com;
location /static/ {
root /home/suly;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/suly/suly.sock;
}
}
server {
listen 80;
server_name www.nocmt.com;
return 301 http://nocmt.com$request_uri;
}
网友评论