0
如何爲同一配置的多個域服務,而不需要複製每個域的服務器規則配置?多個域沒有重複配置
- example.com
- example.org
- example.de
- example.ro
Nginx的配置:
upstream example_live {
server 127.0.0.1:8300;
}
server {
listen 80;
server_name example.com example.org example.de example.ro;
access_log /var/log/nginx/example.access.log;
error_log /var/log/nginx/example.error.log;
location/{
proxy_pass http://example_live/VirtualHostBase/http/example.??:80/example/VirtualHostRoot/;
include /etc/nginx/ps.cfg/proxy.conf;
}
include /etc/nginx/cfg/base.conf;
}
但隨着proxy_pass聲明我要插入一個URL(XXX ?? - > xxx.com)這個網址將被用作「主要」領域的所有進一步的請求.. 1請求 - > xxx.org proxy_pass ... /VirtualHostBase/http/xxx.com:80/... 所有其他要求使用到xxx.com – user966660
即可添加一個重寫命令來將其他主機重寫爲主要主機。就像:if($ host〜「***。org | de」){rewrite「^。* $」http://***.com permanent;} – TroyCheng