# Nginx 著配置文件已经引用了本文件
# include /home/java/nginx_confs/*.conf;

# 指定的负载均衡 采用权重的方式,如果没有服务,Nginx即便权值再高,也不会去访问!
upstream loginServerAPI {
	server 127.0.0.1:18080  weight=1;
	#server 127.0.0.1:9000  weight=10;
}

upstream roomServerAPI {
	server 127.0.0.1:18085  weight=1;
	#server 127.0.0.1:9000  weight=10;
}

upstream shopServerAPI {
	server 127.0.0.1:18081  weight=1;
	server 127.0.0.1:18181  weight=1;
	#server 127.0.0.1:9000  weight=10;
}

upstream friendcircleServerAPI {
	server 127.0.0.1:18083  weight=1;
	#server 127.0.0.1:9000  weight=10;
}

upstream friendServerAPI {
	server 127.0.0.1:18082  weight=1;
	#server 127.0.0.1:9000  weight=10;
}

upstream areaServerAPI {
	server 127.0.0.1:18084  weight=1;
	#server 127.0.0.1:9000  weight=10;
}

upstream skillServerAPI{
	server 127.0.0.1:18086  weight=1;
}

upstream WxPublic {
	server 127.0.0.1:19980;
}

upstream webshow {
	server 127.0.0.1:19980;
}

upstream lottery {
	server 127.0.0.1:18089;
}

upstream serverManager {
	server 127.0.0.1:18999;
}

server
{
	listen 80;
	server_name www.ahxunliao.com;
	
	location / {
			return 301 https://www.ahxunliao.com;
    	    #root /www/wwwroot/www.52zhenliao.com/;
    	    #index index.html index.htm index.jsp index.php;
    }
}

server
{
	listen 443 ssl;
	server_name www.ahxunliao.com;
	charset utf-8;

    ssl_certificate /home/java/nginx_confs/5886786_www.ahxunliao.com.pem;
	ssl_certificate_key /home/java/nginx_confs/5886786_www.ahxunliao.com.key;
	
	ssl_session_cache    shared:SSL:1m;
	ssl_session_timeout  5m;
		
	ssl_ciphers  HIGH:!aNULL:!MD5;
	ssl_prefer_server_ciphers  on;
	
	location / {
    	    root /www/wwwroot/www.52zhenliao.com/;
    	    index index.html index.htm index.jsp index.php;
    }
}

# 让80端口,根据不同的请求路径,访问不同的接口!
server
{
    listen 80;
    server_name 47.100.252.203;
    
    location ^~ /login/ {
    	    proxy_pass http://loginServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /room/ {
    	    proxy_pass http://roomServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /shop/ {
    	    proxy_pass http://shopServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /friendcircle/ {
    	    proxy_pass http://friendcircleServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /friend/ {
    	    proxy_pass http://friendServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /area/ {
    	    proxy_pass http://areaServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ^~ /skill/ {
    	    proxy_pass http://skillServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

     location ^~ /WxPublic/ {
    	    proxy_pass http://WxPublic/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    
     location ^~ /lottery/ {
    	    proxy_pass http://lottery/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ^~ /serverManagerDO/ {
    	    proxy_pass http://serverManager/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
	
	location ^~ /redenvelop/ {
    	    proxy_pass http://127.0.0.1:18090/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }


    location / {
    	    root /www/wwwroot/www.52zhenliao.com/;
    	    index index.html index.htm index.jsp index.php;
    }
    
    # 指定请求状态码 跳转指定页面
    error_page 500 502 503 504 404 /404.html;

    # 定义自己的404页面
    location = /404.html {
         root  /home/java/nginx_html;
         index index.html index.htm index.jsp index.php;
    }

    # 放行所有的静态资源
    location ~.*\.(jpg|jepg|gif|css|png|ico|js|ico)?$ {
    	    # 跳转自己的错误页面
         root /home/java/nginx_html/;   
    }
    
    access_log  /home/java/nginx_logs/java_login.log;
    error_log   /home/java/nginx_logs/java_login.log;
}


# 让80端口,根据不同的请求路径,访问不同的接口!
server
{
    listen 80;
    server_name www.52zhenliao.com;
    
    location ^~ /login/ {
    	    proxy_pass http://loginServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /room/ {
    	    proxy_pass http://roomServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /shop/ {
    	    proxy_pass http://shopServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /friendcircle/ {
    	    proxy_pass http://friendcircleServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /friend/ {
    	    proxy_pass http://friendServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /area/ {
    	    proxy_pass http://areaServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ^~ /WxPublic/ {
    	    proxy_pass http://WxPublic/zhenliaowms/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
	
	location ^~ /lottery/ {
    	    proxy_pass http://lottery/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ^~ /serverManagerDO/ {
    	    proxy_pass http://serverManager/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
	
	location ^~ /redenvelop/ {
    	    proxy_pass http://127.0.0.1:18090/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /download/ {
    	   
         #root /www/wwwroot/www.52zhenliao.com/zhenliaoapp;
         return 301 https://zhenliaoapp.oss-cn-hangzhou.aliyuncs.com/%E6%9E%95%E8%81%8AApp%E6%B5%8B%E8%AF%950.1.7.apk;
    }

    
    location /download {
    	   
         #root /www/wwwroot/www.52zhenliao.com/zhenliaoapp;
         return 301 https://zhenliaoapp.oss-cn-hangzhou.aliyuncs.com/%E6%9E%95%E8%81%8AApp%E6%B5%8B%E8%AF%950.1.7.apk;
    }


    location /android-download {			
		proxy_pass  https://bsppub.oss-cn-shanghai.aliyuncs.com/VKCEYUGU-a4c0e5f5-696a-4622-9d6a-5e5f04f310bf/9c8c6f96-82f0-4819-b5eb-084be0d76bc0.apk;
    }
     
    location /apple-download {
		return 301 https://apps.apple.com/cn/app/id1595022234;
    }

    location  /invite {
         alias /www/wwwroot/invite/;
          index zl.html index.html index.htm index.jsp index.php;
    }
    
    location  /private {
         alias /www/wwwroot/private/;
         index index.html index.htm index.jsp index.php;
    }

    
    # 指定请求状态码 跳转指定页面
    error_page 500 502 503 504 404 /404.html;
    
    # 定义自己的404页面
    location = /404.html {
         alias  /home/java/nginx_html;
         index index.html index.htm index.jsp index.php;
    }

   # location /404.html/~.*\.(jpg|jepg|gif|css|png|ico|js|ico)?$ {
    #     root  /home/java/nginx_html/;
    #} 

    # 放行所有的静态资源
    #location ~.*\.(jpg|jepg|gif|css|png|ico|js|ico)?$ {
    #     root /www/wwwroot/www.52zhenliao.com/;
    #} 
    

    location / {
    	    root /www/wwwroot/www.52zhenliao.com/;
    	    index index.html index.htm index.jsp index.php;
    }

    # 放行所有的静态资源
    location ~.*\.(jpg|jepg|gif|css|png|ico|js|ico|json)?$ {
        root /www/wwwroot/www.52zhenliao.com/;
    }
    
    access_log  /home/java/nginx_logs/java_login.log;
    error_log   /home/java/nginx_logs/java_login.log;
}



# 配置Https 让https端口,根据不同的请求路径,访问不同的接口!
server
{	
    listen 443 ssl;
    server_name www.52zhenliao.com;
    charset utf-8;

    	    ssl_certificate      6136168_52zhenliao.com.pem;
	    ssl_certificate_key  6136168_52zhenliao.com.key;
	
	    ssl_session_cache    shared:SSL:1m;
	    ssl_session_timeout  5m;
		
	    ssl_ciphers  HIGH:!aNULL:!MD5;
	    ssl_prefer_server_ciphers  on;

    location ^~ /login/ {
    	    proxy_pass http://loginServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /room/ {
    	    proxy_pass http://roomServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /shop/ {
    	    proxy_pass http://shopServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /friendcircle/ {
    	    proxy_pass http://friendcircleServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /friend/ {
    	    proxy_pass http://friendServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
        
    location ^~ /area/ {
    	    proxy_pass http://areaServerAPI/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ^~ /WxPublic/ {
	    #proxy_pass http://WxPublic/zhenliaowms/;
	    alias /home/java/wechat_publicpay/;
	    index getcode.html;
    	    #proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    #proxy_set_header X-Real-IP $remote_addr;
    	    #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }    

	location ^~ /lottery/ {
    	    proxy_pass http://lottery/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ^~ /serverManagerDO/ {
    	    proxy_pass http://serverManager/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
	
	location ^~ /redenvelop/ {
    	    proxy_pass http://127.0.0.1:18090/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
	
    location /apple_login {
		proxy_pass  http://740969606.vaiwan.com/zhenliaowms/apple/login;
    }


    location /android-download {
		return 301 https://bsppub.oss-cn-shanghai.aliyuncs.com/VKCEYUGU-a4c0e5f5-696a-4622-9d6a-5e5f04f310bf/9c8c6f96-82f0-4819-b5eb-084be0d76bc0.apk;
    }

    location /apple-download {
		return 301 https://apps.apple.com/cn/app/id1595022234;
    }
    
    # 隐私协议
    location  /private {
         alias /www/wwwroot/private/;
         index index.html index.htm index.jsp index.php;
    }
	
	# 服务协议
    location  /service {
         alias /www/wwwroot/service/;
         index index.html index.htm index.jsp index.php;
    }
	
    # 新手指引
    location  /point {
         alias /home/java/point;
         index index.html index.htm index.jsp index.php;
		 autoindex on;
    } 

    # 猜歌游戏
    location ~/guessMusic {
         root /home/java/;
         index index.html index.htm index.jsp index.php;
		 # autoindex on;
    } 
	
	# 猜歌游戏图片
	location ~/guessMusic/*\.(jpg|jepg|gif|css|png|ico|js|ico|json)?$ {
        root /home/java/;
    }
	
	# 测试新手指引
    location  /pointT/ {
         alias /home/java/pointT/;
         index index.html index.htm index.jsp index.php;
		 # autoindex on;
    }

	# 测试新手指引 
    location  /pointT/^~\.(gif|jpg|jpeg|png)$ {
         alias /home/java/pointT/img;
    }
	

    # 苹果支付
    location  /ApplePayReback {
         return 301 http://740969606.vaiwan.com/zhenliaowms/applePay/setIapCertificate;
    }
    
    location  /invite {
         alias /www/wwwroot/invite/;
         index zl.html index.html index.htm index.jsp index.php;
    }

        # 放行所有的静态资源
    location /invite\.(jpg|jepg|gif|css|png|ico|js|ico|json)?$ {
        alias /www/wwwroot/invite/;
    }


	#location /zhenliaoapp {
      #   alias /home/java/apple/;
	#	index apple-app-site-association.json;
    #}

    location /uni-universallinks/__UNI__00DF92B {
    		default_type application/json; 
   		return 200 '{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "NTM4YTW7QA.com.hefeixunliao.zhenliao",
                "paths": [ "/zhenliaoapp/*"]
            }
        ]
    }
}';	
    }

   	location /zhenliaoapp {
   		default_type application/json; 
   		return 200 '{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "NTM4YTW7QA.com.hefeixunliao.zhenliao",
                "paths": [ "/zhenliaoapp/*"]
            }
        ]
    }
}';
    }


    location /download {
         return 301 https://zhenliaoapp.oss-cn-hangzhou.aliyuncs.com/%E6%9E%95%E8%81%8AApp%E6%B5%8B%E8%AF%950.1.7.apk;
    }

    location  /download/ {
         return 301 https://zhenliaoapp.oss-cn-hangzhou.aliyuncs.com/%E6%9E%95%E8%81%8AApp%E6%B5%8B%E8%AF%950.1.7.apk;
    }

    location  /update/ {
    	    proxy_pass http://loginServerAPI/xunliao/;
    	    proxy_set_header Host $proxy_host; # 修改转发请求头,让该应用可以受到真实的请求
    	    proxy_set_header X-Real-IP $remote_addr;
    	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    
    location / {
    	    root /www/wwwroot/www.52zhenliao.com/;
    	    index index.html index.htm index.jsp index.php;
    }
    
    # 指定请求状态码 跳转指定页面
    #error_page 500 502 503 504 404 /404.html;
    
    # 定义自己的404页面
    #location = /404.html {
         #alias  /home/java/nginx_html;
     #    index index.html index.htm index.jsp index.php;
    #}

    # 放行所有的静态资源
    location ~.*\.(jpg|jepg|gif|css|png|ico|js|ico|json)?$ {
        root /www/wwwroot/www.52zhenliao.com/;
    }

    access_log  /home/java/nginx_logs/java_login.log;
    error_log   /home/java/nginx_logs/java_login.log;
}


特殊说明:
上述文章均是作者实际操作后产出。烦请各位,请勿直接盗用!转载记得标注原文链接:www.zanglikun.com
第三方平台不会及时更新本文最新内容。如果发现本文资料不全,可访问本人的Java博客搜索:标题关键字。以获取最新全部资料 ❤