The original situation is as follows:
Access: Www.test.com hit enter after the browser automatically jump to: www.test.com/index.html
The company's new requirements are as follows:
Access: www.test.com After hitting enter the browser URL is not changed, still display www.test.com, but can access to index.html page.
The configuration is as follows:
#以下为负载均衡设置, unrelated to the topic upstream index {server 123.159.147.369:7069 weight=20 max_fails=2 fail_timeout=30s; Ip_hash; } #以下为server站点设置server {Listen 80; server_name www.test.com; Root/home/wwwroot/index; Location/{index index.html index.htm; Proxy_set_header HOST $host; Proxy_set_header X-real-ip $remote _addr; Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; #此if为判断访问/directory has, matches to the if, jumps to the index configuration item, that is, access to index.html. if (!-e $request _filename) {Proxy_pass http://index; }} error_page 502 503 504/50x.html; Location =/50x.html {root/usr/share/nginx/html; } #静态文件请求location设置, not related to the topic location ~. *\. (HTML|HTM|GIF|JPG|JPEG|BMP|PNG|ICO|TXT|JS|CSS) $ {root/home/wwwroot/index; Expires 30d; }}
Nginx Configuration homepage does not display index.html home is the display domain name