標籤:nginx 隱藏index.html
公司原有的需求是敲網域名稱後自動跳轉到index.html頁面,其它的動態網頁面全部轉寄到後面tomcat處進行解析,並且瀏覽器的地址也添加了index.html,如:
訪問:www.test.com 敲斷行符號後瀏覽器中自動跳轉致: www.test.com/index.html
今天公司提出一個新的需求,如:
訪問:www.test.com 敲斷行符號後瀏覽器中url不變,配置如下:
upstream index {
server 123.159.147.369:7069 weight=20 max_fails=2 fail_timeout=30s;
ip_hash;
}
server {
listen 80;
server_name www.test.com;
root /Disk/var/www/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 ( !-e $request_filename ) {
proxy_pass http://index;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
root /Disk/var/www/index;
expires 30d;
}
}
本文出自 “精忠報國” 部落格,請務必保留此出處http://xinsir.blog.51cto.com/5038915/1562570
nginx 隱藏index.html