nginx配置问题
发布于 8 年前 作者 im-here 3379 次浏览 来自 问答

现在一台服务器上跑了gm,web,qh,mb 4个网站,最开始只有gm,web,qh 3个。今天我加了mb之后,发现访问mb的时候,有一定几率跳到web上,不知道什么原因。 下面上配置:

    upstream nodejs__upstream_gm {
		server 127.0.0.1:8001 weight=1;
	}
	upstream nodejs__upstream_web {
		server 127.0.0.1:8002 weight=1;
	}
	upstream nodejs__upstream_qh {
		server 127.0.0.1:1337;      	
	}		
	upstream nodejs__upstream_mb {
		server 127.0.0.1:3000;      	
	}	
    server {
        listen       80;
        server_name  www.域名.com;
        location / {
            root   html;               
            index  index.html index.htm;                
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Nginx-Proxy true;
            proxy_pass   http://nodejs__upstream_web;
        }
        #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 gm.域名.com;			
        location / {
            root   html;
            index  index.html index.htm;
			proxy_pass   http://nodejs__upstream_gm;            
            client_max_body_size 10m;      
            client_body_buffer_size 128k;   
        }		
		# 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 	qh.域名.com;		
        location / {
            root   html;
            index  index.html index.htm;
            proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Nginx-Proxy true;
			proxy_pass   http://nodejs__upstream_qh;			
			proxy_read_timeout 10;
        }				
		# 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 mb.域名.com;		
		location / {
			root   html;
            index  index.html index.htm;
            proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Nginx-Proxy true;
			proxy_pass   http://nodejs__upstream_mb;		
			proxy_read_timeout 10;		
		}				
		# redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

3 回复

抱歉,最近对与nginx多站点管理很感兴趣,但碰到个问题,能帮忙解答一下吗?网上找了半天答案都没找见正确的QQ截图20160714201513.png

@winterZhao 你这是同一个地址绑了多次导致的。 错误已经告诉你了 Address already in use

好的,谢谢了,但是感觉有点怪异,后续有问题再请教好了,谢谢了

回到顶部