语法 | location [ = | ~ | ~* | ^~ ] uri { … }location @name { … } |
默认值 | - |
上下文 | server, location |
location = / {
[ configuration A ]
}
location / {
[ configuration B ]
}
location /documents/ {
[ configuration C ]
}
location ^~ /images/ {
[ configuration D ]
}
location ~* \.(gif|jpg|jpeg)$ {
[ configuration E ]
}
请求“/”匹配配置A,
请求“/index.html”匹配配置B,
请求“/documents/document.html”匹配配置C,
请求“/images/1.gif”匹配配置D,
请求“/documents/1.jpg”匹配配置E。
(1)修改nginx.conf配置文件
server {
listen 80;
server_name ;
access_log logs/myfmt.log myfmt;
location / {
root /mnt;
autoindex on;
}
location /aabb {
proxy_pass http://192.168.20.102:8080/;#带上/访问该url对应的首页,
#不带/ 访问http://192.168.20.102:8080/aabb
}
}
(2)重新启动nginx
[root@node1 html]# systemctl restart nginx
(3)访问测试