nginx反向 Proxy多個tomcat 配置解決因404問題js css無法載入問題 myeclipse tomcat配置 tomcat 下載 eclipse配置tomcat

來源:互聯網
上載者:User
首先nginx tomcat 的安裝解壓.網上資料很多.不予贅述.

這裡主要是使用nginx 實現對多個tomcat的代理配置. 首先nginx 的設定檔為conf/ngins.conf;

描述情境 有8080連接埠下Tomcat1下項目A.

有8090連接埠下tomcat2下項目B.

......

通過使用一個網域名稱+(不同)項目名 訪問不同的tomcat下的項目.

設定檔如下:(均在conf檔案內添加即可 不刪除或修改其他內容).

server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;

location /Name1 {
#root html;
proxy_pass http://localhost:8080/A ;
proxy_redirect http://host:8080 http://$host:$server_port;//這個配置是將我們的host主機名稱和連接埠號碼,被host:8080所替代.不然因為網域名稱問題,載入js,css檔案會報404錯誤.
index index.html index.htm;
}
location /Name2 {
#root html;
proxy_pass http://localhost:8090/B;
proxy_redirect http://host:8090 http://$host:$server_port;
index index.html index.htm;
}

..........省略

}

配置儲存,重啟.吐槽一下nginx的重啟運行.很麻煩.我是在工作管理員內直接停止後重啟的.

以上即可實現 localhost+A-------訪問tomcat A項目

localhost+B-------訪問tomcat B項目

以上就介紹了nginx反向 Proxy多個tomcat 配置解決因404問題js css無法載入問題,包括了tomcat 配置方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.