2015-04-06 101 views
0

我剛剛使用Nginx,所以目前我有這個在我的默認文件。使網址看起來更好

location/{ 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header X-Forwarded-For $remote_addr; 
      proxy_set_header Host $host; 
      proxy_pass http://127.0.0.1:3000; 
     } 

    location /templates/ { 
       autoindex on; 
       root /home/user/go/src/app/; 
      } 

所以我的網址看起來像下面的鏈接,這取決於我在哪一頁:

http://localhost:80/templates/index.html 

我怎樣才能讓Nginx的重新格式化我的URL看起來是這樣的:

http://localhost:80/index.html 

回答

0

您必須添加這樣的位置塊

location/{ 
      # ... 
      root /home/user/go/src/app/; 
} 

有關位置的更多信息here

+0

我有一個像這樣的位置塊,但上面提供的代碼指向我的HTML文件所在的目錄。 – freetoplay 2015-04-06 02:13:52

+0

您可以替換該位置塊如果它尚未被您的Web應用程序使用 – IgorP 2015-04-06 02:40:26