前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >windows nginx根据请求地址配置反响代理(同一个ng端口)

windows nginx根据请求地址配置反响代理(同一个ng端口)

作者头像
有一只柴犬
发布2024-01-25 10:43:37
发布2024-01-25 10:43:37
16000
代码可运行
举报
文章被收录于专栏:JAVA体系JAVA体系
运行总次数:0
代码可运行
代码语言:javascript
代码运行次数:0
复制
#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;
    sendfile        on;
    keepalive_timeout  65;

    upstream driver-interface{
	server ip1:8081 max_fails=0;
        #server ip2:8082 max_fails=0;
    }

    upstream driver-admin{
	#server 218.66.19.173:8081 max_fails=0;
        server 192.168.3.21:8082 max_fails=0;
    }
    

    server {
        listen       80;
        server_name  localhost;

        location /drive/mobile/{    //这里控制接口(mobile)代理跳转
            root   html;
            proxy_redirect    off;
            proxy_set_header  Host $host:80;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
            index  index.html index.htm;
            proxy_pass  http://driver-interface;
       	    proxy_redirect  default;        
	 }
        location ~ .*/(admin|js|css|img|images) {   //这里控制管理后台(admin)代理跳转,由于后台有样式,js以及图片,前缀不包含admin。所以也需要在这里配置
            root   html;
            index  index.html index.htm;
            //一下是将请求的域名重新转发到页面(分页中,或直接获取请求域名的需要,如果不配置激昂读取到http://driver-interface)
            proxy_redirect    off;
            proxy_set_header  Host $host:80;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass  http://driver-admin;
       	    proxy_redirect  default;        
	 }

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2014-09-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档