带=好位精准匹配,不会被正则覆盖,什么不带为一般匹配,一般匹配会被正则覆盖!!!!
port port;
server serername;
方式1:
locatiom /regex{
proxy_pass http://ip:port
}
方式二:
locatiom /regex{
proxy_pass http://ip:port/
}
当访问:http://servername:port/regex/api/user 时
方式一代理后的路径为: http://ip:port/regex/api/user 会把匹配到的路径全部带上
方式二代理后的路径为: http://ip:port/api/user /regex 只是作为匹配标识不会带上
方式一合方式二的区别就在于是否有/标识符。有标识符代表关闭,标识符只有在servername:port后面加才有意义。
root和alias区别
#####root
location /static{
root html
}
#####alias
location /target{
alias html/static
}
root方式 http://ip:port/sttaic /static 会被当做路径
alias方式 http://ip:port/ /target 相当于标识位,并不会当做路径