1.页面配置
路径配置
location /html {
#root /etc/nginx; #访问地址:/etc/nginx/html/index.html
alias /etc/nginx; #访问地址:/etc/nginx/index.html
index index.html;
}
root与alias主要区别在于nginx如何解释location后面的uri,这会使两者分别以不同的方式将请求映射到服务器文件上。
root的处理结果是:root路径+location路径
alias的处理结果是:使用alias路径替换location路径
alias是一个目录别名的定义,root则是最上层目录的定义。还有一个重要的区别是alias后面必须要用"/"结束,否则会找不到文件的。。。而root则可有可无
使用alias标签的目录块中不能使用rewrite的break
代理
location /api {
proxy_pass http://127.0.0.1:8080;
#include proxy.conf;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
client_body_buffer_size 10m;
proxy_conn