如何设置nginx索引

这里是基于端口4000服务的服务http://example.com ,我现在可以访问http://example.com/index.html 。 当我访问http://example.com ,我也想要访问index.html 。 这是我的nginx设置:

 map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name example.com ; location / { root /wwwroot/product/example.com/programs/web.broswer/app; index index.html; proxy_pass http://localhost:4000; # 映射到本地端口#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; # configuration支持websocket proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } 

现在,path/不是index.html的资源。

index指令不能用于proxy_pass位置。 但是,您可以使用以下内容明确地将/index.html映射到完全匹配位置:

 location = / { rewrite ^ /index.html; } 

执行内部redirect,或者:

 location = / { return 301 /index.html; } 

执行外部redirect。

看到这个和这个细节。