在小作坊的实际生产中,由于服务器的紧缺,往往只有一台nginx,一个端口,但又需要我们在nginx里面配置多个web前端工程。
我们就需要用到nginx的location进行代理。
下面是配多个静态工程:
location / {
root /app/nginx/frontier/dist;
index index.html ;
add_header X-Frame-Options SAMEORIGIN ;
}
location /gongchengA/ {
alias /app/nginx/frontier/gongchengA/;
index index.html ;
add_header X-Frame-Options SAMEORIGIN ;
}
location /gongchengB/ {
alias /app/nginx/frontier/gongchengB/;
index index.html ;
add_header X-Frame-Options SAMEORIGIN ;
}
location也可以配置多个代理
location / {
root /app/nginx/frontier/dist;
index index.html ;
add_header X-Frame-Options SAMEORIGIN ;
}
location /gongchengA/ {
alias /app/nginx/frontier/gongchengA/;
index index.html ;
add_header X-Frame-Options SAMEORIGIN ;
}
location /gongchengB/ {
alias /app/nginx/frontier/gongchengB/;
index index.html ;
add_header X-Frame-Options SAMEORIGIN ;
}