语法规则 匹配优先级 使用示例 # t.c => /index location = / { proxy_pass http://127.0.0.1:8888/index; }
# http://t.c/static/react.development.js => /test-nginx/react.development.js location ^~ /static/ { root /home/uftp/test-nginx/; }
# http://t.c/bizhi1.jpg => /test-nginx/static/assets/bizhi1.jpg location ~* \.(gif|jpg|jpeg|css|js|ico)$ { root /home/uftp/test-nginx/static/assets/; }
# http://t.c/bizhi_sensitive.png 命中 casesensitive/bizhi_sensitive.png location ~ \.png$ { root /home/uftp/test-nginx/static/casesensitive/; }
# http://t.c/api/plmnji => http://127.0.0.1:8888/apitt/plmnji location ^~ /api { proxy_pass http://127.0.0.1:8888/apitt; }
# http://t.c/test/react/react.dev.js => http://127.0.0.1:8888/testreact/react.dev.js 不会匹配下面的规则,被上面的规则优先匹配了
# http://t.c/test/react/akkk => http://127.0.0.1:8888/testreact/akkk location ^~ /test/react { proxy_pass http://127.0.0.1:8888/testreact; }
# http://t.c/test/qwerty => http://127.0.0.1:8888/test/qwerty location ^~ /test { proxy_pass http://127.0.0.1:8888/test; }
# http://t.c/vue/dasdas => http://127.0.0.1:8888/thisisvue/dasdas location /vue { proxy_pass http://127.0.0.1:8888/thisisvue; }
使用示例 # t.c => /index location = / { proxy_pass http://127.0.0.1:8888/index; }
# http://t.c/static/react.development.js => /test-nginx/react.development.js location ^~ /static/ { root /home/uftp/test-nginx/; }
# http://t.c/bizhi1.jpg => /test-nginx/static/assets/bizhi1.jpg location ~* \.(gif|jpg|jpeg|css|js|ico)$ { root /home/uftp/test-nginx/static/assets/; }
# http://t.c/bizhi_sensitive.png 命中 casesensitive/bizhi_sensitive.png location ~ \.png$ { root /home/uftp/test-nginx/static/casesensitive/; }
# http://t.c/api/plmnji => http://127.0.0.1:8888/apitt/plmnji location ^~ /api { proxy_pass http://127.0.0.1:8888/apitt; }
# http://t.c/test/react/react.dev.js => http://127.0.0.1:8888/testreact/react.dev.js 不会匹配下面的规则,被上面的规则优先匹配了
# http://t.c/test/react/akkk => http://127.0.0.1:8888/testreact/akkk location ^~ /test/react { proxy_pass http://127.0.0.1:8888/testreact; }
# http://t.c/test/qwerty => http://127.0.0.1:8888/test/qwerty location ^~ /test { proxy_pass http://127.0.0.1:8888/test; }
# http://t.c/vue/dasdas => http://127.0.0.1:8888/thisisvue/dasdas location /vue { proxy_pass http://127.0.0.1:8888/thisisvue; }
以上就是nginx中location配置规则详解全部内容,感谢大家支持。
查看更多关于nginx中location配置规则详解的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did20652