NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
love
V2EX  ›  NGINX

nginx 要设置主页显示指定文件的内容要怎么做?

  •  
  •   love · May 16, 2019 · 2173 views
    This topic created in 2555 days ago, the information mentioned may be changed or developed.

    我想把 /* 指定到我的后端程序, 但是单独把 / 指定到一个静态文件 /myapp/static/index.html

    如果是

    location = / {
      alias /myapp/static/index.html;
    }
    
    location / {
      proxy_pass http://127.0.0.1:8000;
    }
    

    会导致 error log: "/myapp/static/index.htmlindex.html" is not a directory

    如果

    location = / {
      alias /myapp/static/;
    }
    

    就会 404, 这是要闹哪样。

    怎么才能指定 / 到那个 index.html 呢?

    Supplement 1  ·  May 16, 2019
    解决了。

    之前 google 的这个文章有错误 https://www.tollmanz.com/nginx-location-match-homepage/
    还要加上 location = / {} 最终是

    location = / {} #这里一定要加一个空的语句,不知道为啥
    location = /index.html {
    alias...
    }
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   953 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:09 · PVG 04:09 · LAX 13:09 · JFK 16:09
    ♥ Do have faith in what you're doing.