1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
      nginx+tomcat單個(gè)域名及多個(gè)域名配置教程

      項(xiàng)目開發(fā)接近尾聲,開始著手在生產(chǎn)環(huán)境部署項(xiàng)目,開發(fā)階段部署項(xiàng)目都沒用nginx。項(xiàng)目是采用SOA架構(gòu),多系統(tǒng)開發(fā),主要包括服務(wù)系統(tǒng)、中臺(tái)系統(tǒng)、后臺(tái)系統(tǒng)、金融系統(tǒng)、接口系統(tǒng)、調(diào)度系統(tǒng)、報(bào)表系統(tǒng)等。這類分布式的系統(tǒng),一般也都會(huì)用到nginx來做負(fù)載均衡

      專注于為中小企業(yè)提供成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)瀏陽免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了1000多家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

      從公司剛成立就進(jìn)來,趕鴨子上架來做架構(gòu)師,負(fù)責(zé)公司的所有研發(fā)事情,搭建公司的整個(gè)技術(shù)架構(gòu),起初的所有核心業(yè)務(wù)代碼基本都由自己親自把關(guān)來進(jìn)行編碼。系統(tǒng)也從最初的只有一個(gè)pc端,發(fā)展到如今pc中臺(tái)、后臺(tái)、android端3個(gè)app、iOS端3個(gè)app,產(chǎn)品越做越多,親自負(fù)責(zé)招聘面試、培訓(xùn)。之前很多時(shí)候都有過無助和苦惱,因?yàn)樨?fù)責(zé)公司整個(gè)架構(gòu),又要負(fù)責(zé)核心業(yè)務(wù)的編碼,技術(shù)難點(diǎn)的攻克,新員工的招聘及培訓(xùn),現(xiàn)在團(tuán)隊(duì)已經(jīng)都發(fā)展到16個(gè)人,而且這全是研發(fā)人員。

      回想這一路,覺得之前看似爬不過去的山也不過如此,也許這就是成長(zhǎng)吧,成長(zhǎng)總是會(huì)伴隨些許汗水與淚水吧。由于是負(fù)責(zé)團(tuán)隊(duì)的所有事情,所以數(shù)據(jù)庫的維護(hù)、遷移數(shù)據(jù)、建索引等性能優(yōu)化,項(xiàng)目部署等所有事情必須得一肩挑,不要問我為什么公司沒有DBA?為什么沒有運(yùn)維?我真的只能給你一個(gè)眼神,讓你慢慢去體會(huì)。

      話不多說,直接開始技術(shù)干貨分享。

      nginx做負(fù)載均衡的優(yōu)勢(shì)網(wǎng)上有很多介紹資料,這里我不再多做介紹。因?yàn)橛泻芏嘞到y(tǒng)要部署,涉及到域名、二級(jí)域名、多個(gè)域名等的部署。在實(shí)際的部署由于對(duì)nginx的不夠熟悉,遇到過很多坑,其中這種多域名的配置,xxxx.com轉(zhuǎn)發(fā)到www.xxxx.com、訪問域名轉(zhuǎn)發(fā)到tomcat里的項(xiàng)目等,現(xiàn)在先總結(jié)一部坑的解決辦法。

      如將xxxx.com這個(gè)域名指向8082端口里的tomcat項(xiàng)目,在做這個(gè)介紹前先講個(gè)插曲,如訪問xxxx.com需轉(zhuǎn)向到www.xxxx.com,這一點(diǎn)很多人都會(huì)忽略。

      現(xiàn)在如果要部署中臺(tái)、后臺(tái)、金融系統(tǒng),找到nginx/conf/nginx.conf,修改配置:

      upstream web{
        server localhost:8082;
      }
      upstream admin{
        server localhost:8083;
      }
      upstream finance{
        server localhost:8084;
      }
      server {
        listen    80;
        server_name finance.xxxx.com;
        #charset koi8-r;
        #access_log logs/host.access.log main;
        location / {
          proxy_pass http://finance;
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        #error_page 404       /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504 /50x.html;
        location = /50x.html {
          root  html;
        }
      }
      server {
        listen    80;
        server_name www.xxx.com;
        #charset koi8-r;
        #access_log logs/host.access.log main;
        location / {
          proxy_pass http://web;
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;      
        }
        #error_page 404       /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504 /50x.html;
        location = /50x.html {
          root  html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #  proxy_pass  http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #  root      html;
        #  fastcgi_pass  127.0.0.1:9000;
        #  fastcgi_index index.php;
        #  fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
        #  include    fastcgi_params;
        #}
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #  deny all;
        #}
      }
      server {
        server_name xxxx.com;
        rewrite ^(.*) http://www.xxxx.com$1 permanent;
      }
      server {
        listen    80;
        server_name admin.xxxx.com;
        #charset koi8-r;
        #access_log logs/host.access.log main;
        location / {
          proxy_pass http://admin;
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;      
        }
        #error_page 404       /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504 /50x.html;
        location = /50x.html {
          root  html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #  proxy_pass  http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #  root      html;
        #  fastcgi_pass  127.0.0.1:9000;
        #  fastcgi_index index.php;
        #  fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
        #  include    fastcgi_params;
        #}
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #  deny all;
        #}
      }

       上面的配置還包括了訪問xxxx.com轉(zhuǎn)向www.xxxx.com的配置,如下:

      server {
         server_name xxxx.com;
         rewrite ^(.*) http://www.xxxx.com$1 permanent;
       }

      nginx的基本配置大致就是這樣,如果綁定多個(gè)域名(不管是一級(jí)域名還是二級(jí)域名),需配置多個(gè)server,你會(huì)發(fā)現(xiàn)這幾個(gè)server配置都差不多,主要是更改server_name及proxy_pass指向即可。upstream節(jié)點(diǎn)其實(shí)就是代理服務(wù)的訪問路徑。

      如果此時(shí)訪問域名,你會(huì)發(fā)現(xiàn)nginx的配置生效了,只是目前顯示的是tomcat的默認(rèn)界面。nginx的配置基本就這樣了,接下來對(duì)tomcat做些配置的修改。找到tomcat里的conf/server.xml,注釋掉默認(rèn)的Host配置,添加如下Host配置:

      
             
             
      

      以上是windows服務(wù)器下的配置,如為linux,只需更改appBase和docBase,指向項(xiàng)目的路徑。tomcat的配置也已經(jīng)完成,重啟tomcat,訪問域名就指向了tomcat里的項(xiàng)目。

      總結(jié)

      以上所述是小編給大家介紹的nginx+tomcat單個(gè)域名及多個(gè)域名配置,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!


      名稱欄目:nginx+tomcat單個(gè)域名及多個(gè)域名配置教程
      當(dāng)前鏈接:http://ef60e0e.cn/article/gphcgh.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        杂多县| 兴城市| 山阳县| 嘉荫县| 封开县| 科尔| 灵山县| 兴业县| 怀宁县| 陵川县| 绿春县| 遂昌县| 威信县| 临猗县| 万盛区| 东乡县| 乐昌市| 宁南县| 凌源市| 鄂温| 东台市| 同心县| 苍梧县| 平顶山市| 营山县| 溆浦县| 罗甸县| 滨州市| 论坛| 怀柔区| 黎平县| 温泉县| 隆化县| 桂平市| 桃江县| 江北区| 台山市| 沭阳县| 台北县| 新蔡县| 永康市|