如何在tomcat前部署一个nginx
生活随笔
收集整理的這篇文章主要介紹了
如何在tomcat前部署一个nginx
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在tomcat應(yīng)用已經(jīng)發(fā)布后,如何在tomcat前部署一個(gè)nginx,可以正常訪問jsp,靜態(tài)資源(html,css,js)
?這里tomcat的端口號(hào)是8888
1 upstream morris { 2 server 127.0.0.1:8888; 3 } 4 5 6 server { 7 listen 80; 8 server_name tooth.xxxx.com; 9 root /usr/share/nginx/html; 10 11 # Load configuration files for the default server block. 12 include /etc/nginx/default.d/*.conf; 13 14 #都沒有匹配就走這個(gè)映射 15 location / { 16 proxy_pass http://morris; 17 } 18 19 20 #location /tooth_resoure/ { 21 # root /mydata/toothapp; 22 #} 23 24 #這里是對(duì)jsp的轉(zhuǎn)發(fā) 25 location ~ \.(jsp|jspx|do|action)?$ 26 { 27 #=============tomcat的資源位置============ 28 root /mydata/toothapp/tooth_resoure; 29 index index.jsp index.jspx index.do; 30 #==========Nginx提供的代理============ 31 proxy_set_header X-Forwarded-Host $host; 32 proxy_set_header X-Forwarded-Server $host; 33 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 34 #=== 如果遇到.jsp .jspx .do .action 的請(qǐng)求就進(jìn)入該服務(wù)器(tomcat)=== 35 proxy_pass http://127.0.0.1:8888; 36 } 37 38 #這里是對(duì)靜態(tài)資源的轉(zhuǎn)發(fā),ip地址寫服務(wù)器的真實(shí)地址 39 location ~ .*\.(html|htm|ico|png|jpg|jpeg|js|css|bmp)$ { 40 proxy_pass http://xx.xx.xx.xx:8888; 41 } 42 43 44 }?
參考:?https://www.cnblogs.com/jalja/p/6117523.html?
? ? ? ? ? ? https://blog.csdn.net/cxm19881208/article/details/65441865
轉(zhuǎn)載于:https://www.cnblogs.com/moris5013/p/9796917.html
總結(jié)
以上是生活随笔為你收集整理的如何在tomcat前部署一个nginx的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MIT Molecular Biolog
- 下一篇: Word 最后一页无法删除-解决办法