1. 程式人生 > >應用已經發布了,如何在tomcat前部署一個nginx

應用已經發布了,如何在tomcat前部署一個nginx

.net host con set 不用 http spa server cnblogs

1在應用已經發布後,如何在tomcat前部署一個nginx,可以正常訪問jsp,靜態資源(html,css,js),而不用修改已有的應用部署環境

 1 upstream   morris {
 2     server  127.0.0.1:8888;
 3 }
 4 
 5 
 6 server {
 7     listen        80;
 8     server_name   tooth.titakid.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

應用已經發布了,如何在tomcat前部署一個nginx