2016-08-18 53 views
0

我已經Nginx的運行在80端口和Tomcat運行在端口8080nginx的前進到tomcat不工作

我把下面的配置在Tomcat的conf/server.xml中:

<Host name="localhost" appBase="web apps" unpackWARs="true" autoDeploy="true"> 
    <Context path="" docBase="examples"> 
     <WatchedResource>WEB-INF/web.xml</WatchedResource> 
    </Context> 

我重新啓動tomcat並打開localhost:8080。我看到示例Web應用程序打開。

我打開nginx的文件/ etc/nginx的/啓用的站點 - /默認和更新的位置配置有:

location/{ 
# First attempt to serve request as file, then 
# as directory, then fall back to displaying a 404. 
try_files $uri $uri/ =404; 
#put in by me 
proxy_set_header X-Forwarded-Host $host; 
proxy_set_header X-Forwarded-Server $host; 
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
proxy_pass http://127.0.0.1:8080/; 
} 

當我打開瀏覽器到localhost,我可以看到Tomcat實例頁面。然而,當我點擊內部像「小服務程序」,我得到一個404

你知道我可以將請求轉發給Tomcat這樣的內容從Tomcat返回Nginx的應用程序的任何鏈接?

感謝 -Sonam

回答

2

您應該從配置中刪除此:

# First attempt to serve request as file, then 
# as directory, then fall back to displaying a 404. 
try_files $uri $uri/ =404; 
+0

感謝。這工作。 – Sonam