天天看點

nginx與tomcat結合,動靜分離

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

nginx虛拟主機段配置

server { 

       listen       80; 

       server_name  www.xxxx.com 192.168.8.62; 

       index        index.html index.htm index.action; 

       root         /var/www/; 

       if ($document_uri ~* "\.xhtml$") { 

           rewrite ^/(.*).xhtml$ /$1.action last; 

       } 

       location ~* \.(action|svl)?$ { 

                include         proxy.conf; 

                proxy_redirect  off; 

                proxy_pass      http://127.0.0.1:8080; 

       location ~ (favicon.ico) { 

                   log_not_found off; 

                   expires max; 

       location ~* ^/(WEB-INF)/ { 

                deny all; 

       location /nginx_status { 

                stub_status on; 

                #auth_basic "nginx status"; 

                #auth_basic_user_file /usr/local/apache/htdocs/.htpasswd; 

                access_log off; 

                allow 192.168.8.253; 

                allow 127.0.0.1; 

tomcat主配置檔案主要部分 

<Host name="www.jinfeicui.com"  appBase="webapps" 

            unpackWARs="true" autoDeploy="true" 

            xmlValidation="false" xmlNamespaceAware="false"> 

            <Context path="/" docBase="/var/www/" reloadable="true" debug="0"> 

            </Context> 

 本文轉自dongfang_09859 51CTO部落格,原文連結:http://blog.51cto.com/hellosa/863095,如需轉載請自行聯系原作者

繼續閱讀