nginx-伺服器多虛擬機器主機配置

來源:互聯網
上載者:User
註:本詳解以D:\nginx-1.6.0此目錄為例

1. 修改D:\nginx-1.6.0\conf裡的nginx.conf檔案。

#user  nobody;worker_processes  2;#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {    worker_connections  2048;}http {    include       mime.types;    default_type  application/octet-stream;    sendfile        on;     include vhost/*.conf; #載入vhost目錄下的虛擬機器主機設定檔}


2. 在D:\nginx-1.6.0\conf目錄下建立vhost檔案夾,作為多虛擬機器主機設定檔目錄。

3. 在D:\nginx-1.6.0\logs目錄下建立html、kcloud、web檔案夾,作為多虛擬機器主機日誌目錄

4. 複製htmlConf.conf、kcloudConf.conf、webConf.conf到D:\nginx-1.6.0\conf\vhost目錄下。

htmlConf.conf為宣傳網站虛擬機器主機的配置,以下是詳細說明:

server {listen 80;server_name aaa.com;error_page  404  /404.html;error_loglogs/html/error.log;location /{ root html; access_log off; index index.html index.htm; autoindex on;expires 5d;break; }} 

webConf.conf為web網站虛擬機器主機的配置,以下是詳細說明:

upstream SMELP {    server 182.254.244.33:8080;    }server {listen 80;server_name bbb.aaa.com;error_page  404  /404.html;error_loglogs/web/error.log;location /{proxy_pass http://SMELP;     proxy_set_header        Host           bbb.aaa.com;            proxy_set_header        X-Real-IP       $remote_addr;            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;     client_max_body_size    1000m;     client_body_buffer_size 128k;  #緩衝區代理緩衝使用者端請求的最大位元組數,            proxy_connect_timeout 90;  #nginx跟後端伺服器連線逾時時間(代理連線逾時)            proxy_send_timeout 90;        #後端伺服器資料回傳時間(代理髮送逾時)            proxy_read_timeout 90;         #串連成功後,後端伺服器回應時間(代理接收逾時)keepalive_timeout 0;            proxy_http_version 1.1;           tcp_nodelay on;           proxy_set_header Connection "";if ( $request_uri ~* /ws/* ) {                return   403;            }}} 

kcloudConf.conf為知識庫虛擬機器主機的配置,以下是詳細說明:

upstream kcloud {   server 182.254.244.33:9090;    }server {listen 80;server_name ccc.aaa.com;error_page  404  /404.html;error_loglogs/kcloud/error.log;location /kcloud{proxy_pass http://kcloud;     proxy_set_header        Host           ccc.aaa.com;           proxy_set_header        X-Real-IP       $remote_addr;           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;     client_max_body_size    1000m;     client_body_buffer_size 128k;  #緩衝區代理緩衝使用者端請求的最大位元組數,           proxy_connect_timeout 90;  #nginx跟後端伺服器連線逾時時間(代理連線逾時)            proxy_send_timeout 90;        #後端伺服器資料回傳時間(代理髮送逾時)            proxy_read_timeout 90;         #串連成功後,後端伺服器回應時間(代理接收逾時)keepalive_timeout 0;            proxy_http_version 1.1;           tcp_nodelay on;           proxy_set_header Connection "";}} 

5. 將靜態html宣傳頁網站檔案複製到D:\nginx-1.6.0\html目錄下。

6. 啟動相應的web服務和知識庫服務,其中web服務以ROOT項目名部署。

7. cmd定位到D:\nginx-1.6.0,輸入start nginx。啟動nginx服務即可。

附資源下載地址:http://download.csdn.net/detail/qq_31204765/9572095

以上就介紹了 nginx-伺服器多虛擬機器主機配置,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.