關(guān)于多站點(diǎn)的配置其實(shí)很簡(jiǎn)單
1.多站點(diǎn):
提示:其實(shí)就是一個(gè)站點(diǎn)一個(gè)server,具體配置自己設(shè)置,例如:
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都指向同一個(gè)網(wǎng)站首頁(yè),如果每個(gè)server都設(shè)置一樣的不但浪費(fèi)資源還影響排名,所以我們需要301重定向,設(shè)置十分簡(jiǎn)單,官方推薦做法(以我的網(wǎng)站為例):
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;
}