如何在tomcat前部署一个nginx
生活随笔
收集整理的這篇文章主要介紹了
如何在tomcat前部署一个nginx
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在tomcat應用已經發布后,如何在tomcat前部署一個nginx,可以正常訪問jsp,靜態資源(html,css,js)
?這里tomcat的端口號是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 #都沒有匹配就走這個映射 15 location / { 16 proxy_pass http://morris; 17 } 18 19 20 #location /tooth_resoure/ { 21 # root /mydata/toothapp; 22 #} 23 24 #這里是對jsp的轉發 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 的請求就進入該服務器(tomcat)=== 35 proxy_pass http://127.0.0.1:8888; 36 } 37 38 #這里是對靜態資源的轉發,ip地址寫服務器的真實地址 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
轉載于:https://www.cnblogs.com/moris5013/p/9796917.html
總結
以上是生活随笔為你收集整理的如何在tomcat前部署一个nginx的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MIT Molecular Biolog
- 下一篇: Word 最后一页无法删除-解决办法