标签:blog pass 静态资源 style span css rri 位置 name
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
标签:blog pass 静态资源 style span css rri 位置 name
原文地址:https://www.cnblogs.com/moris5013/p/9796917.html