首頁 > 運維 > windows維 > 在Windows Nginx 設定多網域時進行多Tomcat轉發

在Windows Nginx 設定多網域時進行多Tomcat轉發

坏嘻嘻
發布: 2018-09-17 11:09:17
原創
3277 人瀏覽過

這篇文章帶給大家的內容是關於如何進行Windows Nginx 配置多域名多Tomcat轉發,有一定的參考價值,有需要的朋友可以參考一下,希望對你有幫助。

Nginx下載:

Nginx下載位址

選擇Windws版本下載,直接解壓縮出來,雙擊可運作。

在解壓縮出來的conf資料夾下開啟nginx.conf文件,編輯如下:

#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
	upstream www.yfscms.com {  
			server 127.0.0.1:8080;      
    }  
	
	upstream www.yfscms.net {
			server 127.0.0.1:9999;
    }
    upstream www.yfscms.cn {  
			server 127.0.0.1:8888;
    }
	upstream weixin.yfscms.com {  
			server 127.0.0.1:8080;
    }
	upstream www.gyhkyl.com {  
			server 127.0.0.1:8899;
    }
	upstream 120.26.234.50 {  
			server 127.0.0.1:8899;
    }
	upstream demo.zcgl.yfscms.com {  
			server 127.0.0.1:7777;
    }
	server {
        listen       80;
        server_name  www.yfscms.com;

        location / {
			index  index.html index.jsp;    
            proxy_pass  http://www.yfscms.com;    
            proxy_set_header    X-Real-IP   $remote_addr;    
            client_max_body_size    100m; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    server {
        listen       80;
        server_name  www.yfscms.net;
        location / {
			index  index.html index.jsp;    
            proxy_pass  http://www.yfscms.net;    
            proxy_set_header    X-Real-IP   $remote_addr;    
            client_max_body_size    100m; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
	server {
        listen       80;
        server_name  www.yfscms.cn;

        location / {
			index  index.html index.jsp;    
            proxy_pass  http://www.yfscms.cn;    
            proxy_set_header    X-Real-IP   $remote_addr;    
            client_max_body_size    100m; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
	server {
        listen       80;
        server_name  weixin.yfscms.com;

        location / {
			index  index.html index.jsp;    
            proxy_pass  http://weixin.yfscms.com;    
            proxy_set_header    X-Real-IP   $remote_addr;    
            client_max_body_size    100m; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
	server {
        listen       80;
        server_name  www.gyhkyl.com;

        location / {
			index  index.html index.jsp;    
            proxy_pass  http://www.gyhkyl.com;    
            proxy_set_header    X-Real-IP   $remote_addr;    
            client_max_body_size    100m; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
	server {
        listen       80;
        server_name  120.26.234.50;
        location / {
			index  index.html index.jsp;    
            proxy_pass  http://120.26.234.50;    
            proxy_set_header    X-Real-IP   $remote_addr;    
            client_max_body_size    100m; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
	server {
        listen       80;
        server_name  demo.zcgl.yfscms.com;
        location / {
			index  index.html index.jsp;    
            proxy_pass  http://demo.zcgl.yfscms.com;    
            proxy_set_header    X-Real-IP   $remote_addr;    
            client_max_body_size    100m; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
登入後複製

規則說明:

1、一個upstream對應一個server

#2、server中的”server_name「跟」proxy_pass「跟upstream對應

以上是在Windows Nginx 設定多網域時進行多Tomcat轉發的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板