Nginx反向代理的配置

原创
2016/09/30 10:47
阅读数 91

1、修改nginx.conf文件如下

user  root;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    upstream maven.mall.com {
	server 192.168.1.243:8081;
    }

    upstream dubbo.mall.com {
	server 192.168.1.243:8090;
    }

    server {
        listen       80;

        location ~/group1/M00{
	       root /opt/fastdfs_storage_data;
	       ngx_fastdfs_module;
	}
    }

    ## maven
    server {
	listen   80;
	server_name maven.mall.com;
	 
	location / {
		proxy_pass_header Server;
		proxy_set_header Host $http_host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Scheme $scheme;
		proxy_pass http://maven.mall.com;
		index  index.html index.htm;
	}
    }

    ## dubbo-tomcat
    server {
	listen   80;
	server_name dubbo.mall.com;
	 
	location / {
		proxy_pass_header Server;
		proxy_set_header Host $http_host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Scheme $scheme;
		proxy_pass http://dubbo.mall.com;
		index  index.html index.htm;
	}
    }
}

2、在hosts中配置如下

192.168.1.243  maven.maven.com
192.168.1.243  dubbo.maven.com

展开阅读全文
打赏
0
4 收藏
分享
加载中
更多评论
打赏
0 评论
4 收藏
0
分享
返回顶部
顶部