首页 > 运维 > windows运维 > 在Windows Nginx 配置多域名时进行多Tomcat转发

在Windows Nginx 配置多域名时进行多Tomcat转发

坏嘻嘻
发布: 2018-09-17 11:09:17
原创
3268 人浏览过

本篇文章给大家带来的内容是关于如何进行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
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板