nginx的server下的location中有一个ngx_http_proxy_module的proxy_pass,本章专门针对这个模块的nginx代理配置和代理出grafana进行一些讲解:
首先,来说说proxy_pass的代理配置:
这个代理配置一共存在五种情况:
首先我们在nginx的root目录下创建一些文件来做测试
echo 'this is a' > a.html
mkdir www aaa
echo 'this is www.a' > www/a.html
echo 'this is aaa.a' > aaa/a.html
第一种情况:
location /www/ { #location /www效果一样
proxy_pass http://127.0.0.1/;
}
用curl http://127.0.0.1/www/a.html,返回的结果是this is a,
用curl http://127.0.0.1/www/www/a.html,返回this is a, /www/www/www/......结果都是一样的
用curl http://127.0.0.1/www/aaa/a.htm, 返回this is aaa.a
第二种情况:
location /www/ { #location /www 效果一样
proxy_pass http://127.0.0.1;
}
用cu