nginx與tomcat結合,動靜分離

我們的網站是nginx+tomcat架構,前端用nginx來處理靜態內容,動態的全交給tomcat來處理。之前的SA配置太過於簡單,而且沒有仔細梳理網站的流程。nginx與tomcat的安裝就不說了,很easy,直接貼配置文件,作個筆記

nginx虛擬主機段配置

  1. server { 
  2.        listen       80; 
  3.        server_name  www.xxxx.com 192.168.8.62; 
  4.        index        index.html index.htm index.action; 
  5.        root         /var/www/; 
  6.  
  7.        if ($document_uri ~* "\.xhtml$") { 
  8.            rewrite ^/(.*).xhtml$ /$1.action last; 
  9.        } 
  10.  
  11.        location ~* \.(action|svl)?$ { 
  12.                 include         proxy.conf; 
  13.                 proxy_redirect  off; 
  14.                 proxy_pass      http://127.0.0.1:8080; 
  15.        } 
  16.  
  17.        location ~ (favicon.ico) { 
  18.                    log_not_found off; 
  19.                    expires max; 
  20.        } 
  21.  
  22.        location ~* ^/(WEB-INF)/ { 
  23.                 deny all; 
  24.        } 
  25.  
  26.        location /nginx_status { 
  27.                 stub_status on; 
  28.                 #auth_basic "nginx status"; 
  29.                 #auth_basic_user_file /usr/local/apache/htdocs/.htpasswd; 
  30.                 access_log off; 
  31.                 allow 192.168.8.253; 
  32.                 allow 127.0.0.1; 
  33.                 deny all; 
  34.        } 
  35.  

tomcat主配置文件主要部分 

  1. <Host name="www.jinfeicui.com"  appBase="webapps" 
  2.             unpackWARs="true" autoDeploy="true" 
  3.             xmlValidation="false" xmlNamespaceAware="false"> 
  4.  
  5.             <Context path="/" docBase="/var/www/" reloadable="true" debug="0"> 
  6.             </Context> 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章