开发者

nginx rule to serve root

开发者 https://www.devze.com 2022-12-27 15:02 出处:网络
I would like to nginx to serve a static file from website root ( : http://localhost:8080/ ) but it serves my proxy pass; 开发者_JAVA百科it serves \"/\" rule instead of \"= /\".

I would like to nginx to serve a static file from website root ( : http://localhost:8080/ ) but it serves my proxy pass; 开发者_JAVA百科it serves "/" rule instead of "= /".

Here is what my nginx config look like :

listen 0.0.0.0:8080;
server_name localhost;

set $static_dir /path/to/static/

location = / {
  # got index.html in /path/to/static/html/index.html
  root $static_dir/html/;
}

location / {
  # ...
  proxy_pass http://app_cluster_1/;
}

Did i miss something ?


Use this one:

location = / {
    index index.html;
}

location = /index.html {
    root /your/root/here;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消