nginx 隱藏index.html

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.